Add WriteData function (untested!)