Loading the whole file into memory is inefficient.  You can
```
last_line = ''
try:
    while True:
        line = logfile.readline()
        if line: last_line = line
        else: return last_line
finally: logfile.close()
```
to ensure you only ever have one line of the file in memory at a time.  This shall save you a pile of swapping when the log file is big !