The original code didn't expand tabs mixed with spaces correctly. It merely replaced each tab with n spaces, which is wrong. This code gets that right. I also added the corresponding test.

I know that most people don't mix tabs and spaces, but it can happen when you occasionally edit someone else's file or use different editor than usually. Those are hard to spot, and I suppose no one wants to get incorrect output just because of that.

The other option would be to simply barf when mixed chars and tabs are detected, but it would be actually more expensive, and IMO way less user friendly...