title: What substitutes xreadlines() in Python 3?
body: <p>In Python 2, file objects had an xreadlines() method which returned an iterator that would read the file one line at a time. In Python 3, the xreadlines() method no longer exists, and realines() still returns a list (not an iterator). Does Python 3 has something similar to xreadlines()?</p>
  
  <p>I know I can do</p>
  
  <pre><code>for line in f:
  </code></pre>
  
  <p>instead of</p>
  
  <pre><code>for line in f.xreadlines():
  </code></pre>
  
  <p>But I would also like to use xreadlines() without a for loop:</p>
  
  <pre><code>print(f.xreadlines()[7]) #read lines 0 to 7 and prints line 7
  </code></pre>