f << endl; is roughly equivalent to fprintf(f, "\n"; fflush(f);. Never use endl unless you really, explicitly want to flush the stream.