Getline help

Here is the problem, I made up this program and compiled it with the Big CC compiler and it worked perfect, just the way I wanted it to work, however I have to switch compilers and get it to work on an xlC compiler which I am not familiar with, and of course the program compiles but does not work how it was suppose to work.

The part that is an error, is where I need to 'copy and paste' a infile. I need control of certain elements of the infile so i can do manipulation on them and run a model program, however I still need the rest of the infile for calculation purposes as well, so my thought was just create an outfile, store what I need control of and outfile it, and then outfile the rest of the infile. Then i can make changes to certain elements and sent it through a loop so I would have multiple runs with the data changing only slighly.

However, what happens now is that I gets through the first run fine, then it fails at the 2nd run b/c it did not copy the infile properly and i get this error

1525-001 The READ statement on the file ram.in cannot be completed because the end of the file was reached. The program will stop.