fix bug: gluing data written through write()