Cool! Knowing C++ will help here, I see it easier to code file editing in good old fashoned C++. ((You young whippersnappers with your "C-script"

))
If I could make a suggestion, what about doing it a little differently? Say, have a key file be an index, and code it so it writes the key in keys.txt, and keyindex.txt. Then, it chooses at random letters and numbers and symbols, then makes that a key. It writes it to both key.txt and keyindex.txt. Then to test it, it reads off the key.txt and compares it with keyindex.txt. If they match up, case and all, it is valid. So, you can have forty million keys, all the same length, and all be different.
(Also in C++ you can have game.key, so it confuses the people, and can't change it from notepad. Or you can include it in game.wrs, for even more security!

)