Transformed pseudocode into actual code for read.TextGrid.