I have this problem, i'm writing an app that transfers files across a network. This is done in packages from 512 bytes. These are read from a file, and sent trough a winsock control. At the other end, these must be written to a file. The problem is when writing it to a file, is is inserted on a new line.

eg:
myfile.dat contains following data:

this is just an example file
no need to pay very much attention to it

When i read some data, like say the first 10 bytes, this would result in "this is ju", when i write this to a file, there is no problem yet, but when the second package arives, containing "st an exam", it must be appended to the first line, not on a new line.

What i get is this file

this is ju
st an exam

what is should be

this is just an exam