Catch an IOError that happens on Ruby 2.0

Would get a #<IOError: closed stream> error on Ruby 2.0
Merge pull request #52 from johnkchow/master

Catch an IOError that happens on Ruby 2.0