In reply to shankar_logic:
I have asked you to use code tags - I have added them for you, again.
If there were any characters in the file after the last data scanned, (like \n) this is the behavior to expect. A better way you be to use the return value of $fscanf
file_read_data = $fopen("stimulus/key_get_data.txt", "r");
trans = encrypt_seq_item::type_id::create("trans");
while ($fscanf (file_read_data, "%h", cipher_key) == 1)) begin
$display("cipher_key = %h",cipher_key);
trans.key = cipher_key;
start_item(trans);
finish_item(trans);
end