Dynamic stack that reads push/pop commands from a file line by line and outputs final result to another file