check for existence before writing to file xy