title: Python: For loop with files, how to grab the next line within forloop?
body: <p>I have a file that I want to get each line at a time, but once it gets to a specific line, I need to get the next few lines information.</p>
  
  <p>Here is a code sample:</p>
  
  <pre><code>rofile = open('foo.txt', 'r')
  for line in rofile:
      print line
      if(line.strip() == 'foo'):
          line = line.next()
          print line
          line = line.next()
          print line
          line = line.next()
          print line
  </code></pre>
  
  <p>When I come back around and loop for the second time, that first print statement should print the 5th line in the file. Is there any possible way to do this?</p>
  
  <p>EDIT: Sorry for not clarifying the details. <code>rofile</code> is a file object that I'm iterating through. Whether <code>next()</code> is the real method to obtain the next line when using a file, I don't know. I don't have much experience with file manipulation in python.</p>