Suppose I had opened to read a text file under name fileOpened
, and it has the following lines:
line1
line2
line3
line4
If I execute fileOpened.readline()
once, the output will be: 'line1'
.
If I execute fileOpened.readline()
again, the output will be: 'line2'
.
My question is:
Is there a method which would allow me to access the previous/last line I 'produced' from the readline()
function from some other function, say arbitrary function lastline()
(readline()
position - one line) on fileOpened.lastline()
would output me: 'line2'
?