def do_stuff_with_two_lines(previous_line, current_line):
    print('--------------')
print(previous_line)
print(current_line)
my_file = open('my_file.txt', 'r')
if my_file:
    current_line = my_file.readline()
for line in my_file:
    previous_line = current_line
current_line = line
do_stuff_with_two_lines(previous_line, current_line)
Прочитать предыдущую строку в файле python