Moved check for null list into function, so that changes after script loading are not ignored.

The use case for this is updating the headings (or removing sections entirely) based on the current directory.