Confirmed in Visual C++ 2013 compiler.
The utf16le uses text mode to open a file.
A text "\r\n" will automatically be converted to "\n" (maybe windows only?). So an output file will be broken.
Anyway, I think we should use binary mode to open a file.