Don't forget that in HTML, line-ending characters in text are treated like spaces. And two spaces together are treated like one space. This is how HTML normalizes text. So that's why your text looks like one line, because that's how HTML works.
If you want to preserve the line endings, you have two options. One is to wrap the text in a <pre> element, which causes the usual normalization rules to not be applied. You may or may not like the way that looks, though. The other option is to replace the line-ending characters by elements, which as you know cause the text to break to the next line. Which is what you want. Make sure that those elements are treated as HTML markup and not as text if you do that.