Corrected a bug where the previous day logfile wasn't being closed properly at midnight, and the new day's file wasn't getting a header printed to it. Added a close() command at line 367.