#!/usr/bin/perl 
$cpl=28;

$file=$ARGV[0];
$_=<>;
$s='\x8b';
if (/^$s/) {
  open IN,"zcat $file |";
} else {
  open IN,"/dev/stdin";
  s/\r//g;
  chomp; 
  $old=$_;
}
open STDOUT,"|less";
while ($_=<IN>) {

s/\r//g;
chomp; 
$new=$_;
$both=$old." ".$new;
if ($new=~/./){
  $count=0;

  $_=$both;
  @for=/(.{1,$cpl})(?:$|\s)/g;
  
  for $word (@for[0..(@for-2)]) {
    $count+=length($word);
    $word =~ s/^\s*//;
    print "$word";
    print "\n";
  }
#  $old=substr($both,($count?$count:0))." ";
  $old =$for[$#for];
} else {
#  $old =~ s/^\s*//;
  print "$old\n\n";
  $old = "";
}
}
print "$old\n\n";
