title: Python outFile.writelines - only first line works
body: <p>I found a line of code that searches for and replaces a string if it appears in text on this answer:</p>
  
  <p><a href="https://stackoverflow.com/questions/7812524/search-for-a-line-that-contains-some-text-replace-complete-line-python">Search for a line that contains some text, replace complete line python</a></p>
  
  <pre><code>outFile.writelines("process.control.timeout=900\n" 
                    if "process.control.timeout" in line else line 
                       for line in process)
  </code></pre>
  
  <p>I modified it and used it three times in a row like so:</p>
  
  <pre><code>def runSearch(self):
      outFile.writelines("aFile=" + aFilename + "\n" if "aFile=" in line else line for line in searchFile)
      outFile.writelines("bFile=" + bFilename + "\n" if "bFile=" in line else line for line in searchFile)
      outFile.writelines("cFile=" + cFilename + "\n" if "cFile=" in line else line for line in searchFile)
  </code></pre>
  
  <p>The problem is, the only line that works is the first one. Why is this and how do I solve it?</p>