In reply to aale:
Use $fscanf instead of $fgets
typedef bit [15:0] uint16_t;
typedef uint16_t uint16q_t[$];
function automatic uint16q_t get_file_lines(string file_name);
int fd;
uint16_t value;
fd = $fopen(file_name, "r");
if (fd) begin
$display("File %s was opened successfully", file_name);
while ($fscanf(fd,"%x",value))
get_file_lines.push_back(value);
end else begin
$display("File %s was NOT opened successfully", file_name);
end
$fclose(fd);
endfunction : get_file_lines