Revision 4

Added output method, error handling, and additional comments