Header Sent error

Hey guys,

I am getting problem in  forward() function defined in engine/lib/elgglib.php

 

if (!headers_sent()) {
               
                 $current_page = current_page_url();
                 if (strpos($current_page, $CONFIG->wwwroot . "action") ===false)
                 
                 $_SESSION['messages'] = system_messages();
                 if ((substr_count($location, 'http://') == 0) && (substr_count($location, 'https://') == 0)) {
                    
                     $location = $CONFIG->url . $location;
                 }
                 
                 header("Location: {$location}");
                 exit;
            }

forward() function returs false because above condition doesnt satisfy. Please help me.