Unless the overall file is huge, probably the easiest way to deal with this (and likely fastest as well) would be to simply read the whole file into memory and save the lines desired...
>> fid=fopen('danny.txt');
>> c=cell2mat(textscan(fid,[repmat('%d',1,5) '%*[^\n]'],'collectoutput',1))
c =
2 4 6 7 3
5 5 3 2 2
5 3 2 4 4
7 4 4 6 7
>> c=c(c(:,1)==5,:)
c =
5 5 3 2 2
5 3 2 4 4
>> fid=fclose(fid);