title: Is file object in python an iterable
body: <p>I have a file "test.txt":</p>
  
  <pre><code>this is 1st line
  this is 2nd line
  this is 3rd line
  </code></pre>
  
  <p>the following code</p>
  
  <pre><code>lines = open("test.txt", 'r')
  for line in lines:
      print "loop 1:"+line
  for line in lines:
      print "loop 2:"+line
  </code></pre>
  
  <p>only prints:</p>
  
  <pre><code>loop 1:this is 1st line
  
  loop 1:this is 2nd line
  
  loop 1:this is 3rd line
  </code></pre>
  
  <p>It doesn't print loop2 at all.</p>
  
  <p>Two questions:</p>
  
  <ol>
  <li><p>the file object returned by open(), is it an iterable? that's why it can be used in a for loop?</p></li>
  <li><p>why loop2 doesn't get printed at all?</p></li>
  </ol>