Fixed. The problem was I defined s as a const, when in fact I needed to increment it in the "rows" for loop.