http://www.perlmonks.org?node_id=1041624


in reply to Perl prints only one line when directed to a file but print to a screen works

As you overwrite your file for every iteration of your outer loop, you might want to either open it outside the loop or open it for appending (in contrast to the name...).