Make accumulated_profit variable global and output each iteration