addmessageheader() cosmetic improvements

844ca6b badly broke `addmessageheader()` because it changed the content to use CRLF line-endings, so searching for the `\n\n` transition between header and body always failed.  However unfortunately a fix was pushed to github `master` just as I had finalized my own independent fix and submitted it as #96.  Therefore I'm resubmitting this which hopefully is a "best of breed" merge of the two approaches.