This regex made it so that `before` in the next line never can contain anything (because it matches the beginning of the `data` string). It therefor can never call finished! when there's any output on the last command? With this change the code seems to work fine for me. I would have added a test if there were any.
…ow net-ssh typically does callbacks