raise ArgumentError when IO.new/IO.open last argument is not a hash or nil