added flush.console() to monitor progress during the looping