cout << name(fname, in) << endl;
cout << name(fname, in) << endl; //this part is completely ignored, can't get it to print again. what am i doing wrong. thank you in advance
Do not loop on !eof(). This does not work the way you expect. eof is set true only after you make a read attempt on the file (line 5). This means after you read the last record of the file, eof is still false. Your attempt to read past the last record sets eof, but you're not checking it there. You proceed as if you had read a good record. This will result in reading an extra (bad) record. The correct way to deal with this is to put the entire cin operation as the condition in the while statement.
@OP - PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/
Hint: You can edit your post, highlight your code and press the <> formatting button.