In write, dio.write the segment directly instead of copying it to the transmit buffer.
Remove putsegment.