Closes #1515, thanks to @AtKaaZ for debugging and pinpointing this function as the root cause for output issues on Windows.