use strict; my $find = "2"; open (NEW, ">", "new.txt" ) or die "could not open:$!"; open (FILE, "<", "high_fanout.txt") or die "could not open:$!"; while () { print NEW if (/$find/); } close (FILE); close (NEW);