#include <iostream>
#include <fstream>
#include <string>
int main()
{
const std::string file_name = "my_file.txt" ;
{
std::ofstream file( file_name, std::ios::app ) ; // open the output file in append mode
// accept a line from the user and append it to the file
std::string line ;
std::getline( std::cin, line ) ;
file << line << '\n' ;
}
{
// for debugging: dump the contents of the (modified) file
std::cout << "\n\nfile now contains:\n---------------\n" << std::ifstream(file_name).rdbuf() ;
}
}