in reply to More Eyes, Please

Your code works for me, but instead of messing around in /tmp yourself you should try installing File::Temp and using that instead.