added readHeader() and writeHeader() methods