The problem is probably that you are trying to create a file in the /tmp directory, which is common in unix based systems, but doesn’t exists on Windows systems.
Try replacing /tmp/defer.txt to something like defer.txt and the file should be created in the same directory where you run your code.