safeWrite() implemented