you really want to check whether mkdir succeeds. Perhaps you don't have permissions to the directory it is in? Perhaps there is a file there of that name?
This is somewhat mitigated by the fact that he shortly afterwards tries to create a file in that directory and checks $! there. So he will notice the error. But good habits are good habits.
Cheers,
Ben