Why Does My LUA Script Send 11 CC Messages Instead of 14?

If Type = 5, this LUA code should send 14 cc messages (to my MIDI monitor) but it sends 11 (sometimes less then 11). What’s wrong? When I print everything in the console, it prints all 14.