Fixed a bug in the number of elements check logic.
Moved the creation of the array out of the ReadArray.