Flush stdout to fix redirected output buffering