I noticed the variable "x" missing I hope will help.

Code:
    for x = programStart to $1767F step 64
       Flash = x
       ERASECODE Flash
    next x