Fixed the program crashing on bad files