Pork: all your scripts work fine, as far as I can see from the code.

Just listen to people who now have told you three times that the log file is not open in the first run. Somehow you always manage to come up with a script that will not print anything.

If you only want to test your code, just remove the '#' from your printf statements for god's sake. Then it prints to the window, and you can at least see what your code does, and can continue with your project. For counting use an int, not a var.