Cleanup: to_zip should be chainable to always reset after to_zip

Change-Id: I24a0bb0b24657cfbc722567550789278926d287c
diff --git a/script/tei2korapxml b/script/tei2korapxml
index e276822..c18f941 100755
--- a/script/tei2korapxml
+++ b/script/tei2korapxml
@@ -262,10 +262,6 @@
         $param |= XCT_LINE_NUMBERS if DEBUG;
         my $tree_data = XML::CompactTree::XS::readSubtreeToPerl($reader, $param);
 
-        $structures->reset;
-
-        $tokens->reset unless $skip_inline_tokens;
-
         # ~ whitespace related issue ~
         $add_one = 0;
         %ws = ();
@@ -304,15 +300,12 @@
           $cons_tok->tokenize($data->data)->to_zip(
             $zipper->new_stream("$dir/$base_dir/" . $cons_tok->name . '.xml'),
             $text_id_esc
-          );
+          )->reset;
 
           $aggr_tok->tokenize($data->data)->to_zip(
             $zipper->new_stream("$dir/$base_dir/" . $aggr_tok->name . '.xml'),
             $text_id_esc
-          );
-
-          $aggr_tok->reset;
-          $cons_tok->reset;
+          )->reset;
         };
 
         # ~ write structures ~
@@ -321,7 +314,7 @@
             $zipper->new_stream("$dir/$_structure_dir/${_structure_file}.xml"),
             $text_id_esc,
             2 # = structure serialization
-          );
+          )->reset;
         };
 
         # ~ write tokens ~
@@ -330,7 +323,7 @@
             $zipper->new_stream("$dir/$_tokens_dir/${_tokens_file}.xml"),
             $text_id_esc,
             $_INLINE_ANNOT # Either 0 = tokens without inline or 1 = tokens with inline
-          );
+          )->reset;
         };
 
         # reinit.