implement global[ly]
use a memstream to prepare the main() body