fixed writeLog function call