file_is_locked: check if file exists before trying to flock it