Fixes #116 - use iterator for document output