lower the minimum version to 1.8.5
add 'optional' parentheses to satisfy less sophisticated grammar
separate hash construction into two lines.

The hash constructor is limited in 1.8.5
use block syntax instead of symbol to method name
use the default character encoding when opening a file

This may cause some bugs if running on a newer ruby version.
remove Array#product

Originally defined in 1.8.7
Directly open a file instead of using an enumerator.

This change will reduce performance on large files, but slow is better than no performance
use block syntax for inject

Same as before: no support for symbol to method lookup in 1.8.5