Important advice for writing scripts:

When something does not work, find out why _before_ you attempt to fix it - not the other way around. When you wildly modify commands, you`ll end up with nonsense and crashes. There are plenty printf examples in the manual and in C books.

If you don't find your printf in the log, the right reaction is not `ugh, it doesn't work`, but `why is this part of my code not executed?`