conventionalized GetStackItem to include resource acquisition
- original version is at PeekStackItem
- also included the option to specify output file in sgs2c