Your code has the following flaws:
1) You do not handle the errors.
2) You do not check the return value of the write operation.
3) You do not seem to wait programatically before writing again. This is not correct. Either use the sync waitForBytesWritten or the async bytesWritten signal to give green light for the next write.
The most critical is probably the last point. It would result "random" behavior how the data is sent out. In this special case, it would probably be sent sequentially as waiting for the input probably takes you longer time, but it is still not stable and robust code to write.