Check for file exists before is_dir, avoiding unwanted errors