but it only puts all the 'a' in one stack, all the 'b' in another and so on... i found out that in inner while loop it enters, does one cycle, but does not stay. I cannot understand why is it so.
Line 4: One of two things is going to cause the while loop to exit. 1) fin's bad bit being set, or 2) ch is not a lower case character.
Since we got to line 4, we know fin is good at line 1 and therefore good at the first iteration of the inner while loop. Presumably, you've already read the first character into ch, although you haven't shown that.
So at line 6, either the get is failing, or it succeeded, but did not get a lower case character.