Why would you need to send the header from within a subroutine that gets called more than once? You're always going to want to return
to the browser no matter what happens, and you're never going to want more than one instance of the header, so why not just print it once within your main script?