// Writing data to a text file
#include <iostream>
#include <fstream>
using namespace std;

int main ()
{
  ofstream myFile("example.txt");

  // check if the file is open
  if (myFile.is_open())
  {
    myFile << "This is first line.\n";
    myFile << "This is second line.\n";
    myFile.close();
  }
  else
    cout << "Unable to open file example.txt";

  return 0;
}
