title: Python: rewinding one line in file when iterating with f.next()
body: <p>Python's f.tell doesn't work as I expected when you iterate over a file with f.next():</p>
  
  <pre><code>&gt;&gt;&gt; f=open(".bash_profile", "r")
  &gt;&gt;&gt; f.tell()
  0
  &gt;&gt;&gt; f.next()
  "alias rm='rm -i'\n"
  &gt;&gt;&gt; f.tell()
  397
  &gt;&gt;&gt; f.next()
  "alias cp='cp -i'\n"
  &gt;&gt;&gt; f.tell()
  397
  &gt;&gt;&gt; f.next()
  "alias mv='mv -i'\n"
  &gt;&gt;&gt; f.tell()
  397
  </code></pre>
  
  <p>Looks like it gives you the position of the buffer rather than the position of what you just got with next().</p>
  
  <p>I've previously used the seek/tell <a href="https://stackoverflow.com/questions/3505479/python-undo-a-python-file-readline-operation-so-file-pointer-is-back-in-origin">trick</a> to rewind one line when iterating over a file with readline().  Is there a way to rewind one line when using next()?</p>