fix duplicate header write