Add write function.