my $infile = q{file.txt}; my $outfile = q{report.txt}; open(my $in_fh, q{<}, $infile ) or die "Couldn't open '$infile' for reading: $!\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";