Upstate Niagara Cooperative, a US dairy farmer co-op, has bought Kraft Heinz's New York state-based cheese factory that had been at risk of closure.