I like this in general, instead of using raw_input, etc, I would like to use optparse.  Here is an example of how we use it for the reftest harness:
http://hg.mozilla.org/mozilla-central/annotate/tip/layout/tools/reftest/runreftest.py#l356

The other thing would be to only open the file you are writing for a small time.  This means after you get your data, then you just open file, write lines, close file:
with open(targetfilename, 'w') as target:
    target.write([alerts])
    ...

that will take care of the closing of your file.

Great start- lets shoot for top notch stuff here and get good habits!