remove whitespace on buffer write