problem in submitting solution involving file reading/writing

I am new in submitting solutions that involve inputting and outputting to/from file. I wrote following program to read the numbers from file named “input.txt” and output the sorted numbers to “output.txt” , yet I am getting incorrect answer. Please help me identify where I am wrong. And, also give the tips that one should know to submit solutions involving reading from file.

I have pasted The question that I was trying to tackle …its link is: http://assessments.reliscore.com/activity/ap/69135/

Thanks. This was my code and the link to question can be found here:

Write a program which will read a bunch of integers from an input file, sort them, and print the sorted result to an output file.

You must read the input from input.txt and you must write the output to output.txt. The input will contain one integer per line, and you’re expected to stop reading when you reach EOF. The output should also have one integer per line.

Warning: Do not print anything else to output.txt. Do not print prompts like “Please enter a number.” The output should not contain anything other than the sorted integers, one per line.

If your input is something like this:

3
4
7
1
5
The output should be

1
3
4
5
7

And Link to the solution is : https://www.codechef.com/viewsolution/12392035