Fixed logging issue causing script failure - I hope - through the addition of the 'logverbose' parameter.  Tidied up logging.  Changed to using the 'course' table to find the course id's.  Moved reporting of the contents of the 'files' table to outside the 'course' loop.