Fixed race condition on file creation