close only if file exists