Hello Dmitri, way in which this code has been written is horrible. It becomes very difficult to grasp for the new person ,what is going on in the code and what's the goal of writing code.
Please use proper variable names while writing the code.
Make indentation proper.
Regarding your problem, it looks like you have confused logic in your last for loop. I feel
Should be done if
is something other than a comma(i.e. your variable dot

)
that is what I can see from this code.Try it out.
Good, Better, Best, Don't take rest until, Good becomes Better, and Better becomes Best.
Sidd : (SCJP 6 [90%] )