Add error handling to IO operations

Right now all operations that involve IO are expected to work out as they are supposed to. If something goes wrong, the errors will be presented as-are instead of being wrapped into application specific output.