Transposition loop should check var i and not var k