Ah, it's a problem with the debugger then. If you follow your program through line-by-line, you'll see that it doesn't update the string properly as it goes along, although it does print them out properly. Strange.
It does seem to be causing errors in my server/client though, because it doesn't seem to want to send the string after that point :(
It does seem to be causing errors in my server/client though, because it doesn't seem to want to send the string after that point :(