check if file exists before reading