I am reading a file in Python line by line and I need to know which line is the last one while reading,something like this:
f = open("myfile.txt")
for line in f:
if line is lastline:
#do smth
From the examples I found it involves seeks and complete file readouts to count lines,etc.Can I just detect that the current line is the last one? I tried to go and check for "\n" existence ,but in many cases the last lines is not followed by backslash N.
Sorry if my question is redundant as I didn't find the answer on SO