Factor out command-line input/output