Fixed cleaning and output the content of the buffer