implement keep_last_line