Yes, I am aware that there exist tools such as (k)LyX now, but as a regular (Perl & Linux) monk I type (La)TeX docs directly in Emacs... ;^)
You were right, I didn't mention that what my script REALLY does is just to COUNT braces, and not to take care of their order, so this was unclear. But I suppose every decent brother out there understood my code... or am I wrong??!
Anyway, TNX! ;^))