net: fix buffer iteration in bytesWritten