fixed compiling errors with file object and if statement