title: Delete last line from text file using fstream
body: <p>I want to remove the last line ("%12345") from some text that is stored in my <code>data.txt</code> file</p>
  
  <p>Can anyone tell me how can I achieve what I want. Sorry I don't have any code yet. If you gave me some examples I really appreciate it.</p>
  
  <hr>
  
  <p><strong>data.txt</strong>:</p>
  
  <blockquote>
    <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
    Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, 
    when an unknown prindfdtersd took a was galley of type and scrambled it to make a type specimen
    book. It has survived not only five centuries, but also the leap into electronic 
    typesetting, remaining essentially unchanged. It was popularised in the 1960s with the 
    release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop
    publishing software like Aldus PageMaker including versions of Lorem Ipsum.<br>
    %12345</p>
  </blockquote>
  
  <pre><code>#include &lt;iostream.h&gt;
  #include &lt;fstream.h&gt;
  main()
  {
       char search[500];
       ifstream inFile;
       ofstream outFile;
       inFile.open("data.txt");
  
       while(!inFile.eof())
       {
            inFile.getline(search,500);
            outFile.open("data.txt");
            outFile.seekp(0,ios::end); //Seek to the end of text file
            //I don't know what to do here to delete last line????            
            outFile.close();
       }
       inFile.close();
       return 0;
  }
  </code></pre>