Considering that you are on a Microsoft platform, have you tried testing the directory you to write to and the file you are writing to (overwriting?) to ensure you have permission to write to it as your user?
$output = $lineValue[0].".cfg";
# begin untested code
use File::Basename; # May be moved to top of script
my $output_dir = File::Basename::dirname $output;
if ( not ( -w $output_dir ) ) {
die "No permission to write to directory $output_dir\n";
}
elsif ( not ( -w $output ) ) {
die "No permission to write to file $output\n";
}
# end untested code
open(my $fh2, ">", $output) or die $!;
Hope that helps.