This serialize-to-file functionality could go up to the base class, to avoid duplicating it in each command.