To prevent a grainy or curdled texture, melt the cheese into the sauce over low heat and stir continuously until the cheese is fully melted and the sauce is smooth. Avoid high heat, as it can cause the cheese to separate.