problem with seek() in file handling
<p>I am using seek in a file-  the file has a bunch of filenames and some logs of a process done on the file- some of these logs have errors. I am going line by line, if i get an error, I want to log everything in between two filenames.</p>

<p>When I use seek, I think that instead of moving it to the line i want it to, it moves it to the character # instead. For example</p>

<pre><code>f=open("fileblah",'r')
while f:
   line=f.readline()
   counter=counter+1
   f.seek(tail_position) # i want the next loop to start from after the error happened.

   if line.startswith("D:")
      header_position=counter
      error_flag=0 #unset error flag
   if line.startswith("error")
        error_flag=1       #set error_flag           
        while(not(line.startswith("D:"): #go until next file beginning
           line=f.readline()
           counter=counter+1
        tail_position=counter #have come to the next filename
</code></pre>

<p>I can see this is highly inefficient, but it doesn't work at all, because f.seek(tail_position) is moving the file pointer to the character # instead of the line #</p>
