Catch an IOError that happens on Ruby 2.0

Would get a #<IOError: closed stream> error on Ruby 2.0