Fixed bugs in file checking