have struct.write() return the length of written data