Added a null pointer check for listed files.