If your fudge comes out grainy or gritty, it's because the sugar didn't completely dissolve when cooking it. Try cooking it a little longer at a slow temperature and stirring less to make sure the sugar dissolves completely. Stirring too much can actually sometimes be a problem when making fudge because it can cause the sugar to crystallize after dissolving.