Improved getopts. Clarified usage. Added closing output reference to log
file.