[Newbies] set variables before initialize and write out files before exit