added function to provide a buffered text writer