Former FBI Director James Comey said Thursday that he kept records of his talks with President Donald Trump because he thought the president might "lie."

In Senate testimony, Comey said he wrote records of his conversations with Trump "immediately" after they took place — something he did not do with Trump's predecessor President Barack Obama — because he was concerned about Trump's conduct.

"I knew there might come a day when I would need a record of what had happened, not just to defend myself, but to defend the FBI and our integrity as an institution and the independence of our investigative function," Comey told the Senate Intelligence Committee.

Comey's detailed statement to the Senate Intelligence Committee, largely based on those memos, alleges that Trump asked him for "loyalty" in a dinner shortly after he took office. Comey also said that he believed Trump was asking him to "drop" an investigation into former national security advisor Michael Flynn.

Comey also said he took steps to ensure he wrote the memos in a way that they would not be labeled classified.

That shows the former FBI chief thought seriously about the consequences when he met with Trump, according to Jeffrey Cramer, a former assistant U.S. attorney for the Northern District of Illinois.

"Comey was thinking three steps ahead of the president by writing the memo and ensuring it couldn't be labeled classified," he said.

Trump abruptly fired Comey last month. The ouster came as he oversaw the FBI's investigation into Russian interference in the 2016 election and possible ties between the Trump campaign and the Kremlin.