Looping through text file, readline() construction fails on large files
<p>In Pthon 2.6 and 2.7 I would have thought that these two constructs would be identical.</p>

<p><strong>Method A</strong></p>

<pre><code>i=0
f=open('fred.txt','r')
for line in f.readline():
    i+=1
print i
</code></pre>

<p><strong>Method B</strong></p>

<pre><code>i=0
f=open('fred.txt','r')
for line in f:
    i+=1
print i
</code></pre>

<p>However, when fred.txt grew to be 74,000 lines, with each line 2684 characters in length, <strong>Method A</strong> prints 2685  while <strong>Method B</strong> prints 74000.  Obviously, Method B is preferred, but why does Method A work for small files but fail for large files?</p>
