One way to do this is to select all the text in the first line and then access the property SelectedText:
>> activeEditor = matlab.desktop.editor.getActive;
>> activeEditor.Selection = [1 1 1 Inf];
>> activeEditor.SelectedText
ans =
This is the first line of this file
, , , . , .