Fixed buf writing data into header