Yesterday I tried to make brownies that started out with me having to melt unsweetened chocolate with butter in a frying pan on the stove. This did not work well. The chocolate kindof mixed with the melted butter, but parts of it remained solid. I then had to let it cool before adding the rest of the ingredients; the butter and chocolate separated, and the chocolate formed small to medium solid globs in the butter.  What did I do wrong? If this were to happen again how would I go about fixing it? Should I add something to counteract this and if so what and how much?  NOTE:    I didn't have unsweetened chocolate so I used Hershey's pure chocolate chipits.  I also used margarine instead of butter but have never had a problem with this substitution before.  
I can think of at least three things that will cause chocolate to seize - which refers to when melted or melting chocolate suddenly becomes hard again:   Using too high a heat.  Double-boiler is the safest, but you can use a saucepan on very low heat. Sugar bloom and other impurities.  You shouldn't get this with baker's chocolate, but if you use any lower-quality chocolate, this can seep into the melting chocolate and cause it to seize. Contact with moisture!  Even a tiny amount will cause it to immediately seize, and it's difficult to recover at that point.   Sounds like you fell into traps #2 and #3 and possibly #1.  I would not melt chocolate in margarine; I'd even be wary of melting it in butter, and find it strange that a recipe would call for that, because both butter and margarine contain water!  Melting chocolate in a liquid can actually help prevent seizing, but you have to use a lot of liquid and the liquid has to be completely melted before you start trying to melt the chocolate.  It's better to use something like a vegetable oil which has no water content if this is what you're trying to do.  So, in summary:   Definitely stay away from the margarine.  Even if you need to use butter, make sure it's completely melted first and try to use only the fat (clarify it). If you can, melt the chocolate and clarify the butter separately and then whisk them together gradually afterward; not only will this help to prevent seizing, but if commenter @roux is correct and the problem isn't one of seizing, this will still help to guarantee that the chocolate melts evenly. Use the best quality chocolate you can find.  Chipits are generally OK to melt on their own, but if they've been sweetened then this may contribute to seizing if other factors are present. Melt in a double-boiler or on very low heat.  