Take the IO-performing code in a single function so later on we can better isolate it for library users.