Replace malfunctioning LOCK_EX with unique temporary filename