Fixed the script for use in Python 2.x