fixed error not flushing stringstream