Flush stdout/err at strategic places