Check if headers were already sent before writing more