title: Add new line to head of log file using Python
body: <p>I'm trying to add a new line in front of a date stamp in a log file. I have the following parts.</p>
  
  <p>Open log file: </p>
  
  <pre><code>f = open("C:\Users\user\Desktop\Log.file")
  </code></pre>
  
  <p>Add a new line in front of the date "25/01/2012" (uniquely identifies each log line).</p>
  
  <pre><code>f.write("\n" + "25/01/2012")
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code>Traceback (most recent call last): 
  File "&lt;pyshell#4&gt;", line 1, in &lt;module&gt;
      f.write('\n' + "25/01/2012")
  IOError: File not open for writing
  </code></pre>