moved printing to cmdline, saving file only if we have contents