if (grep { -f $_ and $_ eq $FilePath } @DirsArray){} else{ open (FILE, $FilePath ) or die "Cannot open file: $!"; printf("\n" . $FilePath . "\n"); while ( $line = ) { push(@outLines, $line); #to be sent to appended large file } close FILE; print (LASTFILES $FilePath."\n"); #prints to second file }