memory-friendly create_corpus using iterators