framework exception handling and refactoring

1. Added error handling
2. Added new test case to read from a file
3. Updated the regular expression