Here is an example of the data I am working with. I would like to extract the line directly following each KEY tag. The files have many thousands of these, so I need to create a loop with textscan or something similar.
Here is where I am at (adapted from a similar question in the past), the code does not seem to be moving the cursor, and instead works for the first one, and then grabs all data after it, instead of just the data following the KEY line.
f = fopen('data.txt', 'rt');
tline = fgetl(f);
while isempty(strfind(tline, '> <KEY>'))
if tline == -1
line = fgetl(f);
if tline ~= -1
data = textscan(f,'%s','Delimiter','\r\n');