my $twig = XML::Twig->new( pretty_print => 'indented', twig_handlers =. { 'level(1) => { sub { $_->flush} }); $twig->parsefile_inplace ( $file, $ext) ; # no ->print after this