add line numbers and close file handle