move writeheader below other header setting