program STRIP(input,output);

const
  end_of_file = #26;
  space = #32;
  cr = #13;
  lf = #10;
  null = '';

var
  ch : char;
  line : string[255];
  newfile,datafile : text;
  infile,outfile : string[80];
  period_pos : integer;
begin
  case paramcount of
    2 : begin
          infile := paramSTR(1);
          outfile := paramSTR(2)
        end;
    1 : begin
          infile := paramSTR(1);
          period_pos := pos('.',infile);
          outfile := copy(infile,1,period_pos) + 'txt'
        end;
    else begin
           writeln('Syntax:  [d:][path]STRIP [d:][path]filename  [d:][path][filename]');
           halt
         end;
  end; {case}
  assign(datafile, infile);
  assign(newfile, outfile);
{$I-}
  reset(datafile);
{$I+}
  if IOresult <> 0 then
    begin
      writeln(infile,' not found');
      halt
    end;
  rewrite(newfile);
  while not eof(datafile) do
    begin
      read(datafile,ch);
      if ch = lf then
        begin
          read(datafile,ch);
          while ch = space do
            read(datafile,ch);
          if ch = cr then
            writeln(newfile,cr,lf);
        end;
      if ch <> cr then
        write(newfile,ch);
    end;
  write(newfile,end_of_file);
  close(datafile);
  close(newfile);
end.
