Fix setting header flag during overwrite