adds flush and close