Fix newlines.

Previously the newline handling modified the actual fragments, causing
multiple runs to always update the newlines.  Handle this appropriately.