generic function write()