Looped Array to print as csv

if (anArray[r][1] ==1);

A good start but flawed

What should happen if the test returns true ?

As written you have explicitly told the program to do nothing, or to be more precise, to execute the code that follows the test up to the first semicolon it encounters, ie, do nothing.