This looks like a flat-out bug in code not exercised by any existing toolkit package. ns_puts just puts a string to the HTTP connection.
Try your fix and if it works submit a bug report and patch to the OpenACS 4 project's bugtracker. You may need to configure the file channel to binary depending on what your string contains (see "fconfigure" in the Tcl docs).