Write with buffer