I was getting the same. The problem is that there is no row 0...

You should use `i+1`:

    var cell = sheet.getRange(12,i+1);