First, yes, letting them write down the credit card number, and your phone number, is the right thing to do. There isn't anything that they can improperly with the two of them that they couldn't do with just the credit card number itself. And having the credit card number written down is no riskier than giving it to someone to process in the back room (they can not only write down whatever they want, but they can also use a small machine to improperly read all the data on the magnetic strip.) So you're at no more risk here, if that's a concern, by providing a phone number as well as the card number. (Personally, if I were the restaurant, I'd ask for a driver's license or other ID as well, but that's just me.)
Second, it's your obligation to figure out how to pay the bill. When you walked in, you presumably thought there were two choices, cash and credit card, and you planned to use the latter. That the restaurant wasn't able to process your card electronically in no way invalidates the second option: you could still pay by credit card. They can quite properly insist that you either (a) pay cash) or (b) give them your credit card, since you knew - going into the restaurant - that those were your two choices. If they had said, for example, that your two choices were (a) cash and (b) dishwashing for several hours, then of course you have an issue (particularly if you did not have any cash on hand or in the bank). So, in summary, no harm, no foul.