Program Decoder;

Const
     BufSize  =  2048;


Var
    SF, DF : File;
NumR, NumW : Word;
C1, C2, C3 : Word;
      R, W : Byte;
      BufR : Array  [ 1..BufSize ] of byte;
      BufW : Array  [ 1..2*BufSize ] of byte;

Begin
  WriteLn;
  WriteLn('Line wrapper, truncates lines to 78 chars');
  WriteLn('Program uses MS-DOS wrapping model - line ends by x0D x0A');

  Assign  ( SF, ParamStr(1) );
  Assign  ( DF, ParamStr(2) );
  Reset   ( SF, 1 );
  ReWrite ( DF, 1 );

  C3 := 0;

    Repeat
     BlockRead ( SF, BufR, SizeOf(BufR), NumR );
     C2 := 0;
        For C1:= 1 to NumR do
         begin
          W := BufR[C1];
          Inc(C2);
          BufW[C2] := W;
          Inc(C3);
          If W=13 then begin Inc(C2); BufW[C2] := 13; end;
        end;
     BlockWrite ( DF, BufW, C2, NumW );
    Until ( NumR =  0 ) or ( C2 <> NumW );

  Close   ( SF );
  Close   ( DF );
End.