rjt, thanks for responding.
The colon is of course the volume separator on Win32, so while it's not a valid Win32 filename character, it is a valid path character supplied to open, (just as you might open C:\Windows\Crash). It of course isn't doing what you expect, and then I don't see how a "volume" of testlog_8- makes any sense. Chopping off the : and anything that follows, and saving a file with what would be the volume name makes even less sense, but it is what it is, I guess. DOS is, well, a bit different. :-)
Have a look at the output from test characters 4 and 5. Those were '/' and '\'. For those two the error given was: No such file or directory : The system cannot find the path specified. It was trying to create a file called '---.log' in a folder that did not exist. If the colon is a valid path character on Windows I would expect the same thing to happen.
I'm not sure why you'd end up with random characters in your output logfile when you are generating the filename,[...],
I don't follow what you mean about random characters in the output files. The print statement wrote to the files that were created successfully except for test character 8, the colon. In that case the file is empty. It seems to be a valid filehandle but the print didn't write to the file and the print seemed to succeed since it returned a true value.