If you want something to show up in a browser, the very first thing that is printed must be the header. That tells the browser what kind of document it is (so it doesn't interpret it as some other MIME type).
No good deed goes unpunished. -- (attributed to) Oscar Wilde