Check that your keyboard component is set to save data.
Is the data supposed to be saved by the same keyboard component? Does the keyboard component end the trial.
Remove code you’ve added to save it manually and declare the variables. They might be causing an issue.