write buf