write to buffer