I have to following cron script that runs daily. As you should be able to see from the code, it outputs the results from reflector to /etc/pacman.d/mirrorlist.
$ cat /etc/cron.daily/update-mirrorlist
#!/bin/bash
reflector -l 5 -r -o /etc/pacman.d/mirrorlist
Sometimes, reflector outputs a empty file and thus a invalid mirrorlist is created.
How can I modify the script above to only write to /etc/pacman.d/mirrorlist IF there is valid output from relfector?