导出Csv文件留下三个空行

i have a working export csv file code which have 3 blank lines before my header row. how do i remove the blank lines? so the header will be at the top.

include("global.php");

$Rid = $_SESSION['Rid'];

if(isset($_REQUEST['Rid']))
    $Rid = $_REQUEST['Rid'];
else
    $Rid = "";

$filename = "$Rid.csv";
$fp = fopen('php://output', 'w');

$header=array("DATE","REFNUMBER","MODEL","DESC","CODE","BAL","QTY");

header('Content-type: application/csv');
header('Content-Disposition: attachment; filename='.$filename);
fputcsv($fp, $header);

$query = "SELECT requisition_tb.daterequested , 
                 requisition_tb.refnumber ,
                 allinvty3.ecr_desc,
                 allinvty3.ite_desc,
                 requisition_tb.itemcode ,
                 requisition_tb.onhand , 
                 requisition_tb.qty 
          from requisition_tb 
     INNER JOIN allinvty3 on requisition_tb.itemcode = allinvty3.in_code 
          where requisition_tb.refnumber='".$Rid."' 
          ORDER BY allinvty3.ecr_desc ASC";

$result = mysql_query($query);
while($row = mysql_fetch_row($result)) {
    fputcsv($fp, $row);
}
?>