Readd write buffer

http://stackoverflow.com/q/17924923/214697