Fixed bug when creating logfile