You cannot make an array change in size after you declare it. Well, you can, but that erases the content of the array. Here is a work around:
When you first declare the array, make it huge (like 65535, considering that is the maximum). Some where in your loop, have a variable counting up to tell how many times you've gone through the loop. On your giant array, have the values continually adding to the array, but always have your 0th term be the number of items in the array (like how StringSplit() returns the strings, but term 0 is how many strings in the array there are). So the extra terms in your array won't be used, but the script can know that by telling how many there are by checking the 0th term.
If that doesn't work for you, you can always have the script run through the database without saving data to see how many terms you will need, then declaring the array and running through it again, this time saving data.
The former method will be faster.