Move file check up, to ensure that the error message is correct.