Fixed bug causing crash if given file is not valid