Comey says his assumption Clinton would win was 'a factor' in the email investigation The former FBI director said he believed Clinton "was gonna beat Donald Trump."

James Comey said his decision to announce that the FBI was going to look back into the Hillary Clinton email investigation just days before the election was influenced by his belief that she would beat Donald Trump and his desire to make sure that the election results were viewed as legitimate.

“I don’t remember consciously thinking about that, but it must have been because I was operating in a world where Hillary Clinton was going to beat Donald Trump, and so I’m sure that it was a factor,” Comey told ABC News' chief anchor George Stephanopoulos in an exclusive interview ahead of the April 17 release of his book, “A Higher Loyalty: Truth, Lies, and Leadership.”

"I don’t remember spelling it out, but it had to have been, that she’s going to be elected president and if I hide this from the American people, she’ll be illegitimate the moment she’s elected, the moment this comes out,” he added.

This comment goes further than what Comey wrote in his book, in which he says, "Like many others, I was surprised when Donald Trump was elected president. I had assumed from media polling that Hillary Clinton was going to win. I have asked myself many times since if I was influenced by that assumption. I don't know. Certainly not consciously, but I would be a fool to say it couldn't have had an impact on me."

Clinton previously has said that she thinks the letter Comey sent to Congress on Oct. 28, 2016, announcing that the FBI would be looking back at the email investigation, just 11 days before the election, killed her chances of winning. When asked about if the letter had done so, Comey said “I hope not. I don’t know. I honestly don’t know. I sure hope not.”

Comey said that part of the reason he chose to write a book about his experiences was to share his perspective, and he hopes readers “try to realize that I'm not trying to help a candidate or hurt a candidate; I'm trying to do the right thing.”

When asked if he would still release the letter if he knew that doing so would help elect Donald Trump, Comey said, “I would. I would.”

He said that on the morning that they were going to release the letter, a colleague asked him if he should consider how the letter could help Trump.

“I paused, and then I said, 'Thank you for asking that question. That's a great question. But the answer is not for a moment because down that path lies the death of the FBI as an independent force in American life. If I ever start considering whose political fortunes will be affected by a decision, we're done,'” Comey said.

Stephanopoulos pressed Comey on the decision, saying, “there's no precedent for putting out information like this at the end of a campaign.”

“I think I did it the way that it should have been done,” Comey said. “I'm not certain of that. Other people might have had a different view. I pray to God no future FBI director ever has to find out.”

Watch the exclusive interview in a special edition of "20/20" on Sunday, April 15 at 10 p.m. ET on ABC.