added flush so that messages can be displayed on the command line while they're in progress