ofstream infinite loop

i ran into a bit of a problem, and after reading the tutorials on streams, i couldn't figure out how to stop this infinite loop.

fout << height << radius_in << thick << thermal << hot << cold;
while ( !fout.eof( ) ) {

fout << height << radius_in << thick << thermal << hot << cold;
} // while loop reading until the end of file

i'm testing this out with 3 lines of input data in a separate input file. i'm trying to get the code to print out the 3 lines of code in an output file, before i advance to harder parts of this assignment. The code produces an infinite amount of lines in the output file, so i was wondering how i can get the code to stop after it prints out the lines ( in this case, 3 from the sample input file); all help appreciated
You'll never reach the end of a file while writing to it?
you are writing to the file while you want to read from it!
Use operator >> with an ifstream object
Topic archived. No new replies allowed.