Guards against 0-len list in demo script.

This adds some trivial list-length fixes, but I think it's worth putting them in. I only noticed because I was on the wrong Wi-Fi when I ran the script the first few times.