I think this portion of your script in the braces is where things are going wrong (the if() function doesn't generally want braces there):
{ dt << Delete Rows (i), i --}
That being said, here's another, perhaps simpler way to get what you want, using JMP's built-in function for selecting duplicates:
dt << Select Duplicate Rows ({:ID, :Value 1, :Value 2});
dt << delete rows;