error handling, read from stdin improved