title: C++ Finding a line from a text file and updating/writing the line
body: <p>I have a bank account file that the program should be able to read. This function works as of now with the use of ifstream. But I want the program to read the 6th line of the text file (which has the value 'balance') and then update it as needed (delete and replace with new value). </p>
  
  <p>I used a for loop to find traverse through the lines. But how do I <strong>update it</strong> when needed? <strong>(Withdrawal and deposit of money updates the balance)</strong></p>
  
  <p>This is the code I have for now:</p>
  
  <pre><code>ifstream file;
  string line;
  file.open ("accounts.txt", ios::in); 
  
  for(int i = 0; i &lt; 6; ++i)    //6 being the 6th line
        {
           getline(file, line);
        }
  </code></pre>
  
  <p>What comes next folks? 
  Thanks :)</p>