      SUBROUTINE MAIN
      LOGICAL*1 GETCH
      LOGICAL*1 C, BUF(512)
      INTEGER INT, WC(2), TWC(2), I
      INTEGER OPEN, GETARG, DITOC
      CALL QUERY(23Husage:  wcnt [file] ...)
      TWC(1) = 0
      TWC(2) = 0
      I=1
23000 IF (.NOT.(GETARG(I,BUF,512).NE.-1))GOTO 23002
      IF (.NOT.(BUF(1) .EQ. 45 .AND. BUF(2) .EQ. 0))GOTO 23003
      INT = 1
      GOTO 23004
23003 CONTINUE
      INT = OPEN(BUF,1)
      IF (.NOT.(INT .EQ. -3))GOTO 23005
      CALL CANT(BUF)
23005 CONTINUE
23004 CONTINUE
      CALL WCOUNT(INT, WC)
      TWC(1) = TWC(1) + WC(1)
      TWC(2) = TWC(2) + WC(2)
      IF (.NOT.( TWC(2) .GE. 10000))GOTO 23007
      TWC(1) = TWC(1) + 1
      TWC(2) = TWC(2) - 10000
23007 CONTINUE
      IF (.NOT.(INT .NE. 1))GOTO 23009
      CALL CLOSE(INT)
23009 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
      IF (.NOT.(I.EQ.1))GOTO 23011
      CALL WCOUNT(1, TWC)
23011 CONTINUE
      I = DITOC(TWC, BUF, 20)
      CALL PUTLIN(BUF, 2)
      CALL PUTCH(10,2)
      RETURN
      END
      SUBROUTINE WCOUNT(INT, WC)
      LOGICAL*1 GETCH
      LOGICAL*1 C
      INTEGER INWORD, WC(2)
      WC(1) = 0
      WC(2) = 0
      INWORD = 0
23013 IF (.NOT.(GETCH(C,INT) .NE. -1))GOTO 23014
      IF (.NOT.(C .EQ. 32 .OR. C .EQ. 10 .OR. C .EQ. 9))GOTO 23015
      INWORD = 0
      GOTO 23016
23015 CONTINUE
      IF (.NOT.(INWORD .EQ. 0))GOTO 23017
      INWORD = 1
      WC(2) = WC(2) + 1
      IF (.NOT.(WC(2) .GE. 10000))GOTO 23019
      WC(1) = WC(1) + 1
      WC(2) = 0
23019 CONTINUE
23017 CONTINUE
23016 CONTINUE
      GOTO 23013
23014 CONTINUE
      RETURN
      END