removed dead code, functioning version, saves to array during execution and writes to file on completion