Check line 22, there's an obvious bug there which will be the source of your problems.

Note that you are shooting your self in the foot by not using proper indentation.
Try and avoid using...