title: very strange behavior in writing to file
body: <p>I have very strange behavior.
  For example,</p>
  
  <pre><code>with open("f","w") as fp:
  fp.write(s) # s is string
  </code></pre>
  
  <p>If I write a lot of data then in the beginning of file I see garbage.</p>
  
  <p>The same thing in the binary file.</p>
  
  <p>If I change the mode from w or wb to a or ab then it's ok.</p>
  
  <p>Do you have any idea ?</p>