Please use code tags when posting code.

I don't know what you've done wrong because I don't know what you think the code above will do. What output did you get, and what output did you expect?