You could either translate all of the linebreaks into break (<BR>) tags with a regexp (ereg_replace() or preg_replace()) or wrap the output in a <PRE> tag.
Using regexps, you may also need to replace tabs, etc with several " " tags to get the same formatting.
The <PRE> tag formats the output on the web page EXACTLY how it is presented. Tabs, spaces, line breaks, etc will all be retained.
Hope this helps.
-Rich