title: Python: File empty while script is running with sequential write operations
body: <p>So I wrote a simple script that writes some lines to a file: </p>
  
  <pre><code>f = open('file.txt','w')
  while(operator): 
        f.write("string")
  f.close()
  </code></pre>
  
  <p>The problem is that while the script is running the file remains empty, only when the script finishes and closes the file, the contents become visible. What is happening and how can I make it so that what the script writes to the file is immediately visible when the script is running?</p>
  
  <p>I'm running BackTrack 5 to run the script. </p>