Pls help taking input from text file and and want to make output into a file

Can you post the whole code for reference? Everything seems to be right here.

And also format the code.