Basically I added a check for datafile.fail() and dumped it out if this returned true.
I only needed to verify if and where it was failing so exceptions would have been (to my mind) overkill.
When I checked the flags immediately after the open() call, the failbit flag was set but the original code didn't look for that so it went merrily on its way, assuming all was well.
As I said, this is code written by the textbook author and it apparently works without modification on Windows.