I just looked at your code. It is identical to mine. You are counting the number of BS's and not pushing, whereas I count the number of BS's and "don't discard". What does "don't discard" mean? In your code it means "push onto another stack". I left the definition open to include an array or string.
The problem with your code is you require linelength. But it's a stack. You have no idea what linelength is, and don't need to. Just pop the characters and when the stack is empty, you're done.