      SUBROUTINE MAIN
      INTEGER FILES (4)
      INTEGER NF, INT, I
      INTEGER GETARG, CREATE
      LOGICAL*1 BUF(512)
      LOGICAL*1 GETCH
      LOGICAL*1 C
      CALL QUERY(22Husage:  tee [file] ...)
      NF = 0
      I=1
23000 IF (.NOT.(GETARG(I,BUF,512).NE.-1))GOTO 23002
      NF = NF + 1
      IF (.NOT.(NF .GT. 4))GOTO 23003
      CALL ERROR (15Htoo many files.)
23003 CONTINUE
      FILES(NF) = CREATE(BUF,2)
      IF (.NOT.(FILES(NF) .EQ. -3))GOTO 23005
      CALL CANT(BUF)
23005 CONTINUE
23001 I=I+1
      GOTO 23000
23002 CONTINUE
23007 IF (.NOT.(GETCH(C,1) .NE. -1))GOTO 23008
      CALL PUTCH(C,2)
      I=1
23009 IF (.NOT.(I.LE.NF))GOTO 23011
      CALL PUTCH(C, FILES(I))
23010 I=I+1
      GOTO 23009
23011 CONTINUE
      GOTO 23007
23008 CONTINUE
      RETURN
      END
