Linewrap fixes

* don't replace double spaces blindly.
* don't blindly add a space at the end of each line. A space seems to be needed if the line is blank to maintain the `| ` sidebar.  If however a space is added to a line that is exactly `linewrap` long, this results in a blank line. So a space is only added to the line if it is otherwise blank.