in reply to Where did I go wrong?

Well the first thing I see is that you neglected to use <code></code> tags around your code so it's a big honking unformatted mess where it's impossible to see what "line 7" is.

Update: And it's been janitored into readability. Fweee.