Can now read in input, and even if there is an error, there are no memory leaks and the program always exits gracefully