Adding output.flush per @ConradIrwin