Replaced throwing of std::ios_base::failure with std::system_error. Than...

...ks to Bjorn Reese for suggesting and submitting a patch for this.