(CNN) -- When "Orange is the New Black" writer Lauren Morelli started working on the series, she didn't realize how much it would also script her future.
As Morelli wrote in an essay for Mic.com in May, writing for the Netflix hit helped her realize that she was gay -- even though at the time, she was married to a man. When production began on "OITNB," Morelli had been wed for five months.
"I realized I was gay in fall 2012, one of my first days on the set," Morelli wrote. "It wasn't so much one thing, but the sum of many small details: how uncomfortable I felt around groups of lesbians or how I considered myself ... a 'not very sexual person.' When considered alone, these seemed like little quirks that made me me."
But on the set of "OITNB," where she helped shape the story of main character Piper (Taylor Schilling) and her relationships, "these small moments came into sharp relief," Morelli continued. "I was finally forced to consider a question that had never, ever occurred to me before ... am I gay?"
That answer, she discovered, was yes. Watching a love scene that she'd written between Piper and Alex (Laura Prepon) unfold in front of the cameras, Morelli said she found her emotions paralleling the show. "I'd found a mouthpiece for my own desires," she wrote in her essay, "and a glimmer of what my future could look like."
According to TMZ, Morelli and her husband of two years, Steve Basilone, have now amicably split and have jointly filed for divorce. The OITNB writer is also reportedly dating one of the show's stars, Samira Wiley, the actress who plays Poussey and who sometimes pops up in Morelli's Instagram feed.
"I went through it all on set: I fell in love with a woman, and I watched my life play out on screen," Morelli wrote on Mic.com. "This is my story, which is messy and nuanced and a constantly moving target, but one I'm grateful for."