test if file before trying to open