Print to a new line of a file

Hello,
How would I print a string to a new line of a file each time the program or function is run. What would I need to do to achieve an output such as :


First Run
Second Run
Third Run
...


Where the first run places the string on the first line, then when the program is executed again, or the function called again it prints a different string on the second line.

Specify ios::app mode when opening the file
 
   ofstream file("file.txt",ios::app);

This allows to append data to the file without clearing text from previous run
Thank You Null!! It did wonders!
Topic archived. No new replies allowed.