c 79 is the maximum number of lines printable vertically
c on the page, and may be changed by substituting in
c this program.
c the lines of text may be up to 80 characters long.
      CHARACTER*80 ATEXT(2,79),ATEST1*1,ATEST2*79,TEXT80
      open(3,file='linect.$$$',status='new')
      IPGNO=0
    9 ILINE=0
   10 READ(1,52,END=991) ATEST1,ATEST2
   52 FORMAT(A1,A79)
      ILINE=ILINE+1
c 71 is the maximum number of lines which will be printed as a
c  vertical block on the page.  if more than 71 lines appear in
c  any entry, the entry will be broken into 71-line groups.
c # is the separator character.  When the computer finds
c a '#' in the first column, it assumes that it can break
c the text there.
      IF (ILINE .LE. 71 .AND. ATEST1 .NE. '#') GOTO 10
      WRITE(3,55) ILINE
   55 FORMAT(I5)
      GOTO 9
  991 CONTINUE
      REWIND 3
      REWIND 1
      DO 171 I1=1,2
      DO 171 I2=1,79
  171 ATEXT(I1,I2)=' '
      LINESL=79
      ISIDE=1
   95 READ(3,55,END=992) ILINE
      IF (ILINE .LE. LINESL) GOTO 35
      GOTO 32
   31 ISIDE=0
      IPGNO=IPGNO+1
      WRITE(2,89) IPGNO
   89 FORMAT('1' 50(1H*),' PAGE ',I5,1X,50(1H*))
      WRITE(2,51) ((ATEXT(I1,I2),I1=1,2),I2=1,79)
      DO 71 I1=1,2
      DO 71 I2=1,79
   71 ATEXT(I1,I2)=' '
   32 LINESL=79
      ISIDE=ISIDE+1
      IF (ISIDE .GT. 2) GOTO 31
   35 DO 40 J1=1,ILINE
      READ(1,50) TEXT80
      ATEXT(ISIDE,80-LINESL)=TEXT80
      LINESL=LINESL-1
   40 CONTINUE
      GOTO 95
  992 CONTINUE
      IPGNO=IPGNO+1
      WRITE(2,89) IPGNO
      WRITE(2,51) ((ATEXT(I1,I2),I1=1,2),I2=1,79)
C     READ(1,50) ((ATEXT(I1,I2),I2=1,79),I1=1,2)
   50 FORMAT(A80)
   51 FORMAT(1X,A68,1X,A68)
      WRITE(*,*) IPGNO,' PAGES WERE PRINTED.'
      CLOSE(3,STATUS='DELETE')
      END
