add writeHeader