Beyond Array length/bounds?

BlitzMax Forums/BlitzMax Beginners Area/Beyond Array length/bounds?

This keeps throwing an error for me.

		WriteMap:TStream = WriteFile(ThisFile)
		For Local yiter:Int = 0 Until MapWidth 
			For Local xiter:Int = 0 Until MapHeight 
				WriteString WriteMap,FactoryMap[xiter,yiter]
			Next
		Next
		CloseStream(WriteMap)


I can confirm that the file exists and is opened correctly as it writes the data in the array to the file.

It crashes with an "Unhandled Exception:Attempt to index array element beyond array length" error and BLide highlights Writestring.

Any ideas what could be causing it?

Thanks :)