• Below is the code for my stored procedure - please take a hard look at where something might go wrong. My own suspicion is in the BCP usage to turn the stream into a file.

    I think that your issue with BCP is simply - it is the wrong tools for this task. BCP is intended to write data to a file on a row by row basis with a separator (e.g. CR/LF) between each row. What you need for this task is a method/tool that will write the individual bytes to a file with the extra separators. This is why the solution you found works.