Think through the flow of the code, and add a couple of print "I'm here\n"; statements. Then ponder the results. This is basic debugging, and one way or another, you're going to have to learn it to advance as a programmer.