loop counter without notebook interface, don't use stringstream