#!/usr/bin/perl


if (@ARGV != 3){
  die "Usage: perl RemoveWordsOnList.pl FileWithWordsToRemove FileToBeRemovedFrom ResultFile\n  The script removes all instances of words in FileWithWordsToRemove from the list FileToBeRemovedFrom, and prints the result to ResultFile.\n";
}

open(FILEDone,$ARGV[0]) or die "Couldn't open file $ARGV[0]\n";
open(FILEFull,$ARGV[1]) or die "Couldn't open file $ARGV[1]\n";
open(FILELeftToDo,">".$ARGV[2]) or die "Couldn't open file $ARGV[2]\n";


while(<FILEDone>){
  chomp;
  $_ =~ s/\r+//g;
  $Done{$_} = 1;
}

while(<FILEFull>){
  chomp;
  $_ =~ s/\r+//g;
  if (! exists $Done{$_}){
    print FILELeftToDo $_ . "\n";
  }
}
