It's best to cook the butter/sugar mixture over low heat until the sugar is dissolved, then boil it. This should help the toffee not be gritty.