flush filehandles and do not close stdout

AST printing was broken on my machine, also pmurias++ found the bug where we
close stdout when this is either not wanted or sane.