check file handle, so it does not crash if the file could not be opened