And sometimes, it doesn't work.
So what's a writer to do with their wonderful square peg and nothing but round holes to stick it in? When the brilliant line of dialogue sounds forced? When the heart-felt scene doesn't make sense? Or the engaging character ends up feeling like a distracting extra?
First, (and this can be the hardest step) accept that it's not going to work. It doesn't matter how great it is, if it doesn't fit into this story, then forcing it to stay will only diminish both sides. When I went to see Logan, I was surprised when they put the Deadpool 2 teaser scene at the front of the movie instead of in the credits like they normally do. But after I watched both, I understood. Without giving any spoilers away, the Deadpool teaser is funny and irreverent while the movie Logan was powerful and intense. If the Deadpool scene had happened after, it would have struck the audience as disrespectful and it would have taken away some of the impact from the finale of the movie.
In this case, some timeline editing allowed the audience to see both but that's not always going to be a possibility. Sometimes, a writer just has to surgically remove the awesome, yet troublesome piece. But then what?
The second step is to save it. I always find it easier to edit out my favourites when I know that I'm not getting rid of them, I'm merely putting them aside to feature at a later date. Sometimes that brilliant character can become the hero or heroine of his or her own story. Or the scene can become the dark moment or highlight in the next book (or the one after that). You can always remind yourself that this is not the last story you will ever write, so there will be other opportunities down the road.
But there will be times where no matter the intention, it's just not going to come together. If that is the case, then sometimes it's necessary to just bite the bullet and consign something to the "wish it could have been" drawer. It can be a hurtful event, so give yourself time to emotionally process it. Call a friend, have a glass of wine or emergency chocolate bar, whatever it will take to let you emerge on the other side, ready to battle the blank page once again.