Had a random list index out of range error for first_line_data, so I have put in some checks