Throw an Exception when the header is already been sent

Please see the details of the discussion at  issue #3990
Looks like you are using spaces for indenting. CakePHP uses tabs. I can fix that up if you get stuck on it.