check file exists first