Check if file exists before query

Removed it late in the night for some reason, but didn't mean to do so.