while (){ chomp; my @words = split /[ \.]/,$_; my @added; for (@words){ push @added,$file2{$_} if exists $file2{$_}; }; s/\.$//; print FILE3 $_,(join ' ',@added),".\n"; }