$partlist = "D:\\scripts\\partlist.txt"; #get the parts that have already been printed open(PARTS, $partlist) || die "Can't open file: $!"; @PARTS= ; close(PARTS); #set counter $found = 0; foreach $PARTS(@PARTS) { if ($PARTS == $ordnum) { $found=1; }} if ($found eq 0){ $verifile = $outbox.$ordnum.".dat"; ##Open output file to write to open(OUTPUT_FILE, ">>$verifile")||die "Can't open file: $!"; print OUTPUT_FILE $these.$happy.$variables close OUTPUT_FILE; else { #nothing }