 <p>I would highly suggest operating line-by-line instead of reading in the entire file all at once (in other words, don't use <code>.read()</code>).</p> <pre><code>with open('tweets.txt', 'r') as fileinput: for line in fileinput: line = line.lower() # ... do something with line ... # (for example, write the line to a new file, or print it) </code></pre> <p>This <a href="http://docs.python.org/2/library/stdtypes.html#file.next" rel="nofollow">will automatically take advantage of Python's built-in buffering capabilities</a>.</p>