check file exists properly