Provide generic write function