with open('my_file.txt') as f:
    line = None
previous = next(f, None)
for line in f:
    handle_line(previous)
previous = line
if previous is not None:
    handle_last_line(previous)
В Python, как проверить, является ли строка последней?