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