Added error handling for bad files