Fix file read check; Use more robust checking