Well, _TALLY also counts the number of copied records of COPY TO, so it's a good advice to use it, but it's not necessary to first SQL-Select data.
One simple idea would be to delete the file you just created, IF _TALLY=0.
An elegant way to not wear out SSDs or in general hard drives, would be using a RAM Disc as first stage and then copy to a real drive if _TALLY>0. It's a bit too late for that nowadays, as SSDs today don't wear out so much anymore on one side and since I actually don't know if there is a RAM disc capable to work on Windows 10 anymore, rather using a virtual hdd or crypto container, which also uses a drive virtualisation. Still a bit over the top, you could really simply write out the file you want to and remove it, when _TALLY=0.
Bye, Olaf.