fixed write headers once