Enumerate instead of our own counter

I also removed trailing whitespaces which messed up the code :)
A comment on why pos has to be increased wouldn't hurt but it seems it's pretty obvious.