flush stdout before calling external programs