in reply to Script works fine in cmd but doesn't print to txt

Your second open for the writing is clobbering the contents of your "report.txt" every time you go through the list of words so it's only going to contain the last word from the last line in "file.txt". You probably want to move that open outside the outer while loop (as well as adding error checking to opening "file.txt" for reading but that's another story).

Edit: Additionally if you formatted things better it'd be clearer what your code is doing and you might could see where the problem is more easily.

Edit again: Meh, fish.

my $infile = q{file.txt}; my $outfile = q{report.txt}; open(my $in_fh, q{<}, $infile ) or die "Couldn't open '$infile' for r +eading: $!\n"; open(my $out_fh, q{>}, $outfile) or die "Couldn't open '$outfile' for +writing: $!\n"; while( <$in_fh> ){ chomp; my @words = split( q{ } ); for my $word (@words) { print $out_fh "$word\n"; } } close( $in_fh ); close( $out_fh ); print "done\n";

The cake is a lie.
The cake is a lie.
The cake is a lie.