Add script to count codes and log to state.txt.