Do not reinvent function for generating unique name for temporary files. Use one of the existing methods: