[eluser]joelrichard[/eluser]
I know this is a rather old thread, but it came up in my search and I, too, had the same problem. It took a bit of doing but I think I'm pretty sure I identified the source of the "leading whitespace" problem.
I had a helper (or a library or a plugin, I don't think that it matters) and there were two extra lines after the closing ?> in the PHP file. Eliminating those lines solved the problem.
So I replaced this
With this
And the newlines went away. It makes sense, too, as this helper code is called before any of the output code. It was also included by default on all my pages and so it was appearing elsewhere.
As a corollary to this if you have any
spaces after your closing ?> they will also end up in your output. So for example "?> " would not be advisable.
In fact, if we go back to what someone said on a different thread then REMOVING the ?> from your files (all of them, if necessary) will help solve this problem in the future. All of the CI files use this technique. I think in mradlmaier's case, he must have had a helper (or similar) file that has whitespace at the end of the file.
Enjoy!
--Joel