Added logging and better handling of errors
- added log file for errors
- added better handling of keyboard interrupt