Fixes the invalid file logic.