Learning impulse control and empathy is exactly what they should be doing at this age. My two are a year older than your two, and they definitely are still learning; they've not done something exactly like this, but this doesn't seem to be particularly out of bounds for children at that age - especially two, which feed off of each other's worst impulses.
I'm not a fan of general grounding, nor am I a fan of writing lines. I don't think, at least at this age, taking away a beneficial activity like playing with friends is particularly helpful in most cases; and writing lines to me makes the "positive lesson" seem like a punishment itself - you don't want to tie introspection and learning a lesson to something like that. I also don't think it's reasonable to expect him to figure it out for himself - this is something you need to teach him. More on this later.
As far as consequences, I strongly prefer having consequences directly relate to the problem. When my older son directly went against instructions (from earlier that day!) and played a multiplayer game online with strangers, at the behest of his friend, I:
- Prohibited that particular game (his favorite, but not his only) for a few weeks
- Took the friend home (this was during a sleepover), but did not prohibit playing together at later times
- Added a parental check to that game (which requires me to type in a code before he can play it)
I combined that with a frank discussion of exactly why it was a problem that he did what he did - why playing multiplayer games with strangers is dangerous - and talked as well about how he could handle this in the future. One thing that I think is very important here is that I'm very clear with my children that they can always appeal decisions to me; if they give good reasons, and it is something I can be flexible about, I usually will be, and if I can't or don't think I should, then I will give them the best explanation I can. When your children understand that their best bet for getting a rule changed is going to you, then they'll do that, rather than being underhanded. It sounds like you're also that way - don't change that just because of this.
Note that I didn't take away his socialization, and didn't dramatically restrict his activities. I think telling a child at any age, but in particular at 8, that he should stay in his room and do nothing but read for multiple days, is either excessive, or pointless - you're taking away a lot of social learning and really just making it harder for him to find something fun-and-acceptable to do. Playing with his friends didn't have anything to do with this - so it's purely punitive.
If you do need to do indirect, punitive consequences, then small consequences are key here, because they allow the child to learn without too much anger or negativity. Start with the smallest thing you can do that still is noticeable. Then build up as needed. If you can take away an hour of screen time, then two, then a day, then two days, then a week, you give yourself more room to work with, and you give him more time to learn. It might take a few whacks at the tree before he learns it's not going to fall - but if you start with a week or more, you don't leave yourself much room to escalate.
The other thing here I think that's worth mentioning is the concept of positive discipline. This is where you don't focus on punishment, but instead treat mistakes as learning opportunities - yes, even when they lie to you or hit you or do something else bad.
The core of positive discipline is that you acknowledge that your child is not "bad", they just did something they shouldn't have; and they did it for a reason. When my older son hits my younger son, he's not doing it because of some defect in his character. He's doing it because he has emotions, and hasn't yet learned how to control those emotions. It doesn't make it right, but it's not coming from some 18th century concept of innate evilness - it has a cause, and something we can address.
The core is to:
Talk to your son about how he is feeling and why he did what he did. Focus on positive language. Find the vocabulary for him that he probably lacks. He may not even know why he did this - so help him find that language. In this case, it probably was a combination of feeling upset that you took away his device, curiousity if he could get away with it, and boredom.
Pair your emotions to his here. Tell him how you feel. Avoid the "disappointed in you" and such language - that's just emotionally bullying him, and probably isn't really what you're feeling if you get down to it (even if it is, try not to use that language - it reinforces that he should be good for you, which is not the message you want - you want him to be good for him). Instead, tell him that you're sad that he did not do what he promised, that you're upset that he took your device, and that you're frustrated that he didn't follow the rules. Use the same kind of language you did with his feelings, when you can.
Talk about how to handle those feelings and emotions next time in a positive way. Give him options - and make sure he has real options. If he lost his game device and wants it back, talk about him coming to you (as it sounds like he did) with options to get it back. Talk about other things he could do that might be fun.
The hardest thing with positive discipline is that it's not instant - especially if it's new - and there will be some times that it doesn't seem like it's working. In those times, you either need to just wait it out - or use what I think of as a safety net, which is where you have realistic limits that you take non-punitive actions if they're broken. (For example, my children the last two weeks or so have been causing trouble at bedtime. We talk to them about it, but ultimately they have to sleep - and so we let them know that if they are roughhousing or causing the other to not sleep, we'll ask one to go to another room; they both value sleeping in the same bedroom. It's not a punishment, and we make it clear; it's just acknowledging reality. We hope that this will eventually sink in.)
There are several books on the topic that are well worth reading (one of which is Positive Dispcline by Jane Nelson, which I found quite useful).
Ultimately whichever way you decide to handle things, the most important thing is to be patient. Consider adding some minor fences that make it a little easier to have impulse control - if you have a Switch or an iPad or similar, they have parental controls that can technologically limit their use. If you really have an actual GameBoy, that's too old for parental controls, but you can put the game cards in a locked drawer and require them to ask you for them (and to return them). The idea here is minor "fences" to make it a bit harder to lose control, not perfect preventive measures; you just want them to have to think twice before doing it, so they're less likely to.
Give them time to learn, and let them make mistakes - I'd far, far rather my nine year old make mistakes now, than be a perfect angel until he's sixteen and then start shoplifting or drinking behind the school, no? Let them make those mistakes now, help them learn from the mistakes, and stay positive!