Fixes #1530. Fixes NPE by using IO.listFiles

Fixes #1530.

Ah, this has caught me many a time too... fun