title: How to safely open/close files in python 2.4
body: <p>I'm currently writing a small script for use on one of our servers using Python.   The server only has Python 2.4.4 installed.</p>
  
  <p>I didn't start using Python until 2.5 was out, so I'm used to the form:</p>
  
  <pre><code>with open('file.txt', 'r') as f:
      # do stuff with f
  </code></pre>
  
  <p>However, there is no <code>with</code> statement before 2.5, and I'm having trouble finding examples about the proper way to clean up a file object manually.</p>
  
  <p>What's the best practice for disposing of file objects safely when using old versions of python?</p>