Accidentally reused “i” twice in nested for loop.  Changed second one to “k”.