It sounds like it is probably getting done and that for some reason the gets not stopping but overruning and causing an error. Weird. It's supposed to return 0 when done, but maybe it needs a "catch" too.
What platform are you running on?