title: Python 2.x find and replace multi line text
body: <p>I know that many questions exist here on finding and replacing text in file using python 2. However being a very new to python, I did not understand the syntax and may be the purpose also will be different. </p>
  
  <p>I am looking for something very simple code lines as in linux shellscript</p>
  
  <pre><code>sed -i 's/find/replace/' *.txt 
  sed -i 's/find2/replace2/' *.txt
  </code></pre>
  
  <p>Can this code work to replace a multiline text</p>
  
  <pre><code>with open('file.txt', 'w') as out_file:
     out_file.write(replace_all('old text 1', 'new text 1'))
     out_file.write(replace_all('old text 2', 'new text 2'))
  </code></pre>
  
  <p>Also, there seems a problem with getting another newline, which I do not want. Any ideas or help?</p>