The lines in populate_log_with_matches() if selected_match < first_match_to_print then first_match_to_print = selected_match will set first_match_to_print to 1 even if it is not set here since handle_edit() sets selected_match = 1.