OP flagged and asked for it to be deleted.
He essentially said that he made a stupid mistake, and that the problem was in another part of his program.
We get lots of flags like this, but we don't really have any strict guidelines for what to do in these situations. Therefore it is up to the moderator's discretion if he/she deletes.
Now, we (in general) don't want to delete good content, as good questions/answers is what StackOverflow is all about. Since the OP asked a bad/incorrect/pointless/localized question, this tips the balance in favor of deletion. I believe this is what the deleting moderator took into account when they deleted the question.
I, on the other hand, disagree.
In general, I don't particularly care if the OP thinks they have asked a stupid question. I believe that if the question cannot be self-deleted due to system rules, or if the question has any value whatsoever, then question should stand. A good answer is a valid reason for the question to stand. If the OP complains about getting downvoted or being embarrassed, tough tittay. As I like to say, it shall stand as a shining beacon to remind you never to do this again.
Since there is value to be had in its entirety (namely, your answer and the rep you gained for your efforts), I've undeleted.