Getting unexpected output of the following code below:
sample.txt
contains:
this is the first line
this is the second line
this is the third line
this is the fourth line
this is the fifth line
this is the sixth line
code:
import sys
f1=open("sample3.txt",'r')
print f1.tell()
for line in f1:
print line
print "postion of the file pointer",f1.tell()
Output:
0
this is the first line
postion of the file pointer 141
this is the second line
postion of the file pointer 141
this is the third line
postion of the file pointer 141
this is the fourth line
postion of the file pointer 141
this is the fifth line
postion of the file pointer 141
this is the sixth line
postion of the file pointer 141
I expect something which shows the file pointer position the end of each line