Split openFileForWrite into windows and unix versions.

It is similar to 186511, but for creating files for writing.