I think this needs to be inside the loop - otherwise second time round there will be a memory leak (as the MCStringRef from the previous time round won't have been released).