Need help with file reading

I was working on a program that reads a sequential file with bank accounts.
The file has three sets of data per line: the account #, the account holder's name, and balance.
Then, I made a program to print the file- and it printed the last line of the file twice.

The difference is that eof() doesn't recognize end-of-file until an actual read is performed. When at end-of-file line 31 doesn't know it yet until line 33 is executed. But line 34 is executed whether at eof or not. That's a common mistake that new programmers do -- IMO eof() is almost a useless function.

If you are dead set on using .eof( ), then correct way is to first read outside the loop, sometimes called a priming read.
Then test .eof( ) in your loop condition, and have a read at the end of the loop body.

Additionally, I would avoid doing chained input as you for any program that you cannot be absolutely sure the input will be correct. If any of the inputs in that sequence are bad, you have no way to recover.