Just checking, but by "doesnt (sic) do anything" do you mean the larger program dies silently?
Some of the usual questions apply:
Are you sure the source file is where you think it is? I see several dies in what look like appropriate places (given my lack of knowledge of the specific modules you're using)
Have you run this under debug? Potentially tedious, but often helpful
a) Are you sure your problem is in the code you posted? b) How do you know? It's very hard to help if a) is not true; it's easier to feel confident that one is not wasting time, if the answer to b) is known.