Fixed bug where write_buffer was not being closed at the end of do()