Why do I get an exception in this simple loop?

Printable View