Made a fix to the Algorithm. (k = k + 1;)