Well it's good to hear my coding is right.....and I tried removing all whitespace, still produces a blank output. Same with putting a \n after @range. I'm completely confused now though.
printing out $line also produces '', so it seems that something's going wrong with parsing the original infile. Guess that's where I need to look. Thanks for confirming my basic code is right folks.
Found it. It's definitely whitespace at the end of the line in the text file. Not sure why $line =~ s/\G //g; didn't work, but I'll figure it out. Thanks for pointing me in the right direction folks!
Last update: $line =~ s/^\s+|\s+$//g; is the regex I was looking for. That does the trick. Thank you all again, I really appreciate the help!