Corrects the runtime implementation of I/O on files with
the access mode ACCESS='STREAM'. This is a collection
of edge-case tweaks to ensure that the distinctions between
stream and direct/sequential files, unformatted or formatted,
are respected where appropriate.
Moves NextInField() from io-stmt.h to io-stmt.cpp --
it was getting too big to keep in a header.
The original version of this patch exposed a problem with
the I/O runtime on Windows and it was reverted. This new
version also fixes that problem; files are now opened on Windows
in binary mode to prevent inadvertent insertions of
carriage returns before line feeds, and those line
endings (CR+LF) are now explicitly generated.
I have a concern here: If fd is <=2, (stdout or stderr), it will be in text mode, which expects a single \n for a newline, but with isWindowsTextFile_ = true, we will write \r\n (which the c-runtime expands to \r\r\n).