   dup needs-escaping? [ escape-quotes enclose-in-quotes ] when ; inline
     
 : write-row ( row -- )
-  [ delimiter> write1 ] [ escape-if-required write ] interleave nl ; inline
+  [ delimiter get write1 ] [ escape-if-required write ] interleave nl ; inline
     
 : write-csv ( rows outstream -- )
-  init-vars
   [ [ write-row ] each ] with-output-stream ;

! Simple CSV Parser
! Phil Dawes phil@phildawes.net

USING: kernel sequences io namespaces combinators unicode.categories vars ;
IN: csv

DEFER: quoted-field

VAR: delimiter
    
! trims whitespace from either end of string
: trim-whitespace ( str -- str )


: (row) ( -- sep )
  field , 
  dup delimiter get = [ drop (row) ] when ;

: row ( -- eof? array[string] )
  [ (row) ] { } make ;
