added an extra flush for stdout