Thanks for all the help. Randal, unfortunately, my employer requires a new protocol, and that's what they're getting :)
The removal of \cM and concatenating with a \n instead of a blank string fixed the problem. Of course, now I'm on to bigger and worse problems, like segfaults - that's how it works though, right?