Check if the file exists before checking the extension.