Added flush() to print progress