closure-based string iterator