function DisplayFile(filename)

% function DisplayFile(filename)
%
% It reads a text file and displays it in the command window
%
% INPUT: filename = a string containing the file name
% Author: Borgo, Soranzo, Grassi 2010

try
    fid=fopen(filename); % open file returning the file id.
    if fid == -1 % file doesn?t open correctly
        disp(sprintf('Unable to open file ''%s'' ',filename));
    else % in this case file opens correctly
        while ~feof(fid) % Start loop. End if eof is reached
            tline = fgetl(fid); % read next line of text from file
            disp(tline); % display text line on command window
        end
        fclose(fid); % close the file
    end
catch
    fclose(fid);
    disp('Something wrong happened');
end