On Windows, the tmpnam function returns a temp filename in the current directory, which has a prepended backslash '\\'.
This subsequently fails the open function.
This patch creates a proper temp filename in the temp folder and makes unlike work by opening the file as short-lived.