      SUBROUTINE MAIN
      LOGICAL*1 BUF(512)
      INTEGER GETARG, OPEN, GETLIN
      INTEGER I, INT
      CALL QUERY(23Husage:  kwic [file] ...)
      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
23007 IF (.NOT.(GETLIN(BUF,INT) .NE. -1))GOTO 23008
      CALL PUTROT(BUF, 2)
      GOTO 23007
23008 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
23013 IF (.NOT.(GETLIN(BUF,1) .NE. -1))GOTO 23014
      CALL PUTROT(BUF, 2)
      GOTO 23013
23014 CONTINUE
23011 CONTINUE
      RETURN
      END
      SUBROUTINE PUTROT (BUF, OUTFIL)
      LOGICAL*1 TYPE
      LOGICAL*1 BUF(100), T
      INTEGER I, OUTFIL
      I=1
23015 IF (.NOT.(BUF(I) .NE. 10))GOTO 23017
      T = TYPE(BUF(I))
      IF (.NOT.(T .EQ. 1 .OR. T .EQ. 2))GOTO 23018
      CALL ROTATE(BUF, I, OUTFIL)
      T = TYPE(BUF(I+1))
23020 IF (.NOT.(T.EQ.1 .OR. T.EQ.2))GOTO 23022
      I = I + 1
23021 T=TYPE(BUF(I+1))
      GOTO 23020
23022 CONTINUE
23018 CONTINUE
23016 I=I+1
      GOTO 23015
23017 CONTINUE
      RETURN
      END
      SUBROUTINE ROTATE(BUF, N, OUTFIL)
      LOGICAL*1 BUF(100)
      INTEGER I, N, OUTFIL
      I=N
23023 IF (.NOT.(BUF(I) .NE. 10))GOTO 23025
      CALL PUTCH(BUF(I), OUTFIL)
23024 I=I+1
      GOTO 23023
23025 CONTINUE
      CALL PUTCH(36, OUTFIL)
      I=1
23026 IF (.NOT.(I.LT.N))GOTO 23028
      CALL PUTCH(BUF(I), OUTFIL)
23027 I=I+1
      GOTO 23026
23028 CONTINUE
      CALL PUTCH(10, OUTFIL)
      RETURN
      END
