# Outside the read loop, after closing input file.... mkdir "$pathname" or die "Error couldn't create new Directory"; open my $OUT1, ">", "$pathname/column.txt" or die "error couldn't open output file"; print $OUT1 "$_\n" for @data1; close $OUT1;