File reading in uvm sequence

Hi i have written a code where i am reading the data from the file. It is working fine but the problem is that the last data is read twice.

 file_read_data = $fopen("stimulus/key_get_data.txt", "r");
      trans = encrypt_seq_item::type_id::create("trans");
      while (!$feof(file_read_data)) begin
         $fscanf (file_read_data, "%h", cipher_key);
         $display("cipher_key = %h",cipher_key);
         trans.key = cipher_key;
	 start_item(trans);
	 finish_item(trans);
      end

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

Thanks Dave.
Finally its working for me. But what are code tags actually means.

*In reply to shankar_logic:*Please format your code with [code] and [/code] tags or [systemverilog] and [/systemverilog] | Verification Academy