Throw an Exception when the header is already been sent

Please see the details of the discussion at  issue #3990
As I said: Bail early would be preferred - and pleae use tabs instead of spaces for indentation.