added error handling and bad input file