How would I go about printing the last line in a text file that is about 612 MB and has about 4 million lines of text consisting of This is a line. So far I have:
File.py
f = open("foo.txt","r+")
datalist = []
for line in f:
    datalist.append(line)
print(datalist[-1])
The only problem that I see with my code is that it uses a lot of memory. I have heard people using os.lseek instead but I do not know how to implement it.