% Step 1: Read in all files using readlines
file1_lines = readlines('24802901.raw2');
file2_lines = readlines('23C02901.raw2');
file3_lines = readlines('23C02902.raw2');
file4_lines = readlines('23C02902 - Copy.raw2');
file5_lines = readlines('23C02901_original.raw2');

% Remove any empty lines
file1_lines = file1_lines(file1_lines ~= "");
file2_lines = file2_lines(file2_lines ~= "");
file3_lines = file3_lines(file3_lines ~= "");
file4_lines = file4_lines(file4_lines ~= "");

% Step 2: Combine lines from file2, file3, file4, and file5
combined_lines = unique([file2_lines; file3_lines; file4_lines; file5_lines]);

% Step 3: Find lines in file1 that are not in the combined lines
lines_to_keep = file1_lines(~ismember(file1_lines, combined_lines));

% Step 4: Write the remaining lines to a new file
writelines(lines_to_keep, '24802901_updated.raw2');

% _updated2
%REMOVED 0 profile from december 2023
%REMOVED LINES CONTAINING DEC
%REMOVED END ABORT DIVES
%ADDED DIVE 68 END DIVE
%ADDED DIVE 68 GPS 02

fprintf('Updated file1 has been saved as "file1_updated.txt".\n');
