Simpler generate_last_line method