Ant error in for loop

We have an ant script to build the component, which used to work fine with Ant 1.7.x and JDK 6.

However, recently, an upgrade was made in which Ant became Ant 1.8.2 and JDK became JDK 7. And after that, the script started to fail.

It is something like this:

As mentioned, initially, it was working properly, but now, it fails with error:

for doesn't support the "begin" attribute

Also, in our script there is an 'if' condition much before this loop. If ant-contrib is not used, then script fails at that if condition itself. However, since script is proceeding this far, it seems that ant-contrib is being used.

So, any idea about this error? That is - how to overcome it, or is there any other way for simple for loop? The value 'count' is read from environment, and we need to perform some operation for 'count' number of times.

Not an Ant expert, but some pointers-
1. Try debugging the ant execution and see which class/lib ant were using.
2. What's the Ant 1.8.2 docs says for 'for' loop, I'm sure there must be some looping elements in ant.