what you are doing is a bit wrong. you read every line in br
("test.txt") and then go through it's characters and checking the same thing over and over searching for some unknown input and removing it
what you want to do is every loop write the current line to the file
something like:
while ((s = br.readLine()) != null) {
if (s.indexOf(infoToRemove) == -1) {
wr.println(s);
}
}
but that's not the best way.
what you want to do is when you create the file that it won't be a meaningless line like:
jason,100,20,Male,Block 1,Ground Floor
jack,200,20,Male,Block 1,Ground Floor
you want, at least for the id to it to be clear. something like
jason,id=100,20,Male,Block 1,Ground Floor
jack,id=200,20,Male,Block 1,Ground Floor
so when you search for it you'll be able to do:
while ((s = br.readLine()) != null) {
if (s.indexOf("id=" +infoToRemove) == -1) {
wr.println(s);
}
}
and it will be exact and won't delete accidentally lines that has other id