take file flush out of main