pattern - file io in cpp