title: Can I save a text file in python without closing it?
body: <p>I am writing a program in which I would like to be able to view a log file before the program is complete. I have noticed that, in python (2.7 and 3), that <code>file.write()</code> does not save the file, <code>file.close()</code> does. I don't want to create a million little log files with unique names but I would like to be able to view the updated log file before the program is finished. How can I do this?</p>
  
  <p>Now, to be clear I am scripting using Ansys Workbench (trying to batch some CFX runs). Here's a <a href="http://www.padtinc.com/blog/the-focus/workbench-and-excel-part-2-driving-workbench-from-excel-with-python" rel="noreferrer">link</a> to a tutorial that shows what I'm talking about. They appear to have wrapped python, and by running the script I can send commands to the various modules. When the script is running there is no console onscreen and it appears to be eating all of the <code>print</code> statements, so the only way I can report what's happening is via a file. Also, I don't want to bring a console window up because eventually I will just run the program in batch mode (no interface). But the simulations take a long time to run and I can't wait for the program to finish before checking on what's happening.</p>