A browser interprets html documents. A plain text is a sub-form of it (so it can be read) but the rules about spaces and end-of line are different.
your real file shold look (if viwed from a text editor) at a minimum like
<html>
<body>
Address earth <br/>
Objective !!
</body>
</html>
This is what your program must write in the file to be readable the way you wanted by a browser.