     input-stream get binary re-decode
     [ count-lines ] with-input-stream* ;
 
+: print-wc ( n name/f -- )
+    [ number>string 8 CHAR: \s pad-head write ]
+    [ bl [ write ] when* ] bi* nl ;
+
 PRIVATE>
 
 : wc ( path -- n )

! Copyright (C) 2016 John Benediktsson
! See http://factorcode.org/license.txt for BSD license

USING: alien.data command-line formatting io io.encodings
io.encodings.binary io.files kernel math math.bitwise
math.vectors math.vectors.simd namespaces sequences
specialized-arrays ;

SPECIALIZED-ARRAY: uchar-16


: run-wc ( -- )
    command-line get [
        wc-stdin f print-wc
    ] [
        [
            dup file-exists? [
                [ wc ] keep dupd print-wc
            ] [
                write ": not found" print flush f
            ] if
        ] map sift dup length 1 > [ sum "total" print-wc ] [ drop ] if
    ] if-empty ;

MAIN: run-wc
