Print out more friendly error if listFiles() fails

listFiles() could return null if the I/O fails, and this currently results in an ugly NPE which is hard to diagnose.