make document iterator more robust, check for empty files