I realize this is supposed to be a nice simple script so I'm not gonna give you all the grief @jlee-r7 gives me on exceptions and all that, but you could do this to minimize the chance of leaving open file handles

````ruby
w = File.open('iplist.txt', 'a')

begin
  File.open('rangelist.txt', 'r') do |f|
    f.each_line do |range|
      ips = Rex::Socket::RangeWalker.new(range)
      ips.each do |ip|
        w.puts("#{ip}")
      end
    end
  end
# rescue all those annoying file exceptions maybe, it's a PITA tho
ensure
  w.close if w
end
````