Check for file before writing