title: Deleting specific line from file
body: <p>These are the contents of my example file:</p>
  
  <p><code>abcdefg hijk lmnopqrstAB CSTAKLJSKDJD KSA FIND ME akjsdkjhwjkjhasfkajbsdh ADHKJAHSKDJH</code></p>
  
  <p>I need to find and delete the 'FIND ME' inside of the file so the output would look like this:</p>
  
  <p><code>abcdefg hijk lmnopqrstAB CSTAKLJSKDJD KSA  akjsdkjhwjkjhasfkajbsdh ADHKJAHSKDJH</code></p>
  
  <p>I have tried the following method of doing getline and then writing all of the contents except the FIND ME into a temporary file and then rename the temporary file back.</p>
  
  <pre><code>string deleteline;
  string line;
  
  ifstream fin;
  fin.open("example.txt");
  ofstream temp;
  temp.open("temp.txt");
  cout &lt;&lt; "Which line do you want to remove? ";
  cin &gt;&gt; deleteline;
  
  
  
  while (getline(fin,line))
  {
      if (line != deleteline)
      {
      temp &lt;&lt; line &lt;&lt; endl;
      }
  }
  
  temp.close();
  fin.close();
  remove("example.txt");
  rename("temp.txt","example.txt");
  </code></pre>
  
  <p>but it doesn't work.
  Just as a side note: the file has NO newline/linefeeds. So the file contents are all written in 1 line.</p>
  
  <p>EDIT:</p>
  
  <p>FIXED CODE:</p>
  
  <pre><code>while (getline(fin,line))
  {
      line.replace(line.find(deleteline),deleteline.length(),"");
      temp &lt;&lt; line &lt;&lt; endl;
  
  }
  </code></pre>
  
  <p>This gets me the results I expected. Thank you everyone for helping!</p>