title: Editing a text file
body: <p>I want to edit a text file, but I'm stuck in finding the correct functions or methods to do so.
  So far I'm able to open a text file and look for a certain string, but I have no idea on how to move the cursor, add or replace information, steps 4 - 7 in my pseudocode shown below.</p>
  
  <p>Can you provide some guidance? Which functions should I use (in case they already exist)?
  A sample 'easy' code would be appreciated as well.</p>
  
  <pre><code>Pseudocode:
  
  1. Open file.
  2. While not eof
  3.    Read file until string "someString" is found.
  4.    Position the cursor at the next line (to where the someString was found).
  5.    If "someString" = A go to step 6. Else go to step 7. 
  6.       Replace the information in whole line with "newString". Go to step 8.
  7.       Add new information "newString_2", without deleting the existing.
  8. Save and close the text file.
  </code></pre>
  
  <p>Thanks.</p>