const NL=CHR(10); {new line}
      FF=CHR(12); {form feed}
      HT=CHR(9); {horizontal tab}
const LASTLINE=59; LASTCHAR=59;
var C,L1,L2:INTEGER; CH:CHAR;
FIRSTCOL:array[0..LASTLINE] of
    record LINE:array[0..LASTCHAR] of CHAR end;
FILENAME: array[1..32] of CHAR;
INFILE,LISTING: TEXT;
begin  
REWRITE(LISTING,'OUTPUT.LST ');
WRITE(OUT,'#'); BREAK(OUT);
C:=0;
repeat
  READ(INP,CH);
  C:=C+1; FILENAME[C]:=CH 
until CH=NL;
RESET(INFILE,FILENAME);
while ~EOF(INFILE) do begin
  L1:=0;
  repeat
    C:=0;
{    with FIRSTCOL[L1] do} begin
      repeat
        READ(INFILE,CH);
        if CH>=' '
        then begin FIRSTCOL[L1].LINE[C]:=CH; C:=C+1 end
        else if CH=HT then repeat
          FIRSTCOL[L1].LINE[C]:=' '; C:=C+1
          until (C mod 8)=0
      until (CH=NL) ! (C>LASTCHAR) ! EOF(INFILE);
{      for C:=C to LASTCHAR do LINE[C]:=' '}
      while C<= LASTCHAR do begin
        FIRSTCOL[L1].LINE[C]:=' '; C:=C+1 end
      end;
    L1:=L1+1
  until (L1>LASTLINE) ! (CH=FF) ! EOF(INFILE);
  L2:=0;
  while L2<L1 do begin
    WRITE(LISTING,FIRSTCOL[L2].LINE);
    if (CH#FF) & ~EOF(INFILE) then begin
      WRITE(LISTING,'            ');
      C:=0;
      repeat
        READ(INFILE,CH);
        if CH>=' '
        then begin WRITE(LISTING,CH); C:=C+1 end
        else if CH=HT then repeat
          WRITE(LISTING,' '); C:=C+1
          until (C mod 8)=0
      until (CH=NL) ! (C>LASTCHAR) ! (CH=FF) ! EOF(INFILE)
      end;
    WRITE(LISTING,NL);
    L2:=L2+1
    end;
  WRITE(LISTING,FF)
  end 
end.
