Error with file I/O system tasks($feof,$fscanf)

In reply to DVEngineer:

module break_continue;
initial
begin
bit [1024:0] cmd;
int x;
int c;
x = $fopen("test.txt");
$display("x=%d",x);
while(!($feof ( x )))
begin
c=$fscanf(x,"%s",cmd);
$display("cmd=%s",cmd);
case(cmd)
" " : continue;
"done": break;
endcase
end
$fclose(x);
end
endmodule

In above code at simulation below errors are coming, please help
$feof : Argument 1 is not a valid file descriptor.
$fscanf : Argument 1 is not a valid file descriptor.

x = $fopen(“test.txt”,“r”); //specify mode while opening file.