Modified extra code added from earlier so it writes to specified log file.