fixed a logical error in checking file status