The error is obvious when you read the code:
new FileIoPermission("completename",'r').assert();
txtb = new TextBuffer();
txtb.fromFile("completename");
Should really be:
new FileIoPermission(completename,'r').assert();
txtb = new TextBuffer();
txtb.fromFile(completename);
Besides, the use of Hungarian Notation in AX is not Best Practice.