fix major bug overwriting file header