Paul Nicholls said text messages were meant for someone else
A jury is considering its verdict on an air cadet instructor said to have had sex with two teenagers, the younger of whom later killed herself.
Paul Nicholls, 39, of Pontygwaith, Rhondda, denies three charges of sexual activity with a 15-year-old and one of attempting sexual activity with her.
He also denies claims during the trial that he had sex with Cherrell Ardle, 13, who was found hanged at her home.
Merthyr Crown Court heard the 15-year-old went to police after Cherrell died.
The older girl, who is now 16, claimed she had also had sex with him.
Prosecutor Jennet Treharne said: "The girl cadet said a sexual relationship had developed between Nicholls and her.
"She said she did not tell anyone in authority what was happening at the time."
Ms Treharne said the girl came forward after Cherrell took her own life.
"She claimed that Cherrell had also been having a sexual relationship with Nicholls and it was her belief his conduct to Cherrell caused her to take her own life."
The older girl told police she had slept with Mr Nicholls 10 times between June and August 2007, before he moved onto Cherrell.
Miss Treharne said: "She said she didn't want to tell anyone at the time that they were having the affair because Nicholls told her it would ruin everything."
Police were told Mr Nicholls had sex with the 15-year-old cadet in his bedroom, his living room and in his car parked on a mountain.
Cherrell Ardle was found hanged at home in late 2007
Miss Treharne said: "The girl believed that sexual activity stopped after two months because he started to act in a similar way with Cherrell."
The court heard Mr Nicholls sent her a text saying he wanted to invite both the girls to have sex.
In one text he allegedly wrote: "I know one is better than none. But now I prefer two."
The court heard that police found several text messages from Nicholls on the both girls' phones.
The girl gave video evidence to police against Mr Nicholls a month after Cherrell's death.
The teenager said Cherrell told her he raped her.
She had earlier told the court she thought it was Cherrell's sexual relationship with Mr Nicholls that "tipped her over the edge".
She has also told the jury how she had sex with Mr Nicholls "on many occasions".
Mr Nicholls denies having sexual relationships with the girls and claimed the text messages where sent by mistake when they should have gone to an older woman friend.
The trial continues.