Refactor []byte return value to io.Writer
Add error handling
Add error handling in main