1. You are working with HTML, so \n is treated as a whitespace. Try adding <br/> tag.
2. Instead of creating a file on disk, you can store that message in a QString and then display it with ui.textBrowser->setHtml( message );