Lol, I'm doing the exact same thing at the moment.
You can't just find a line and delete it. You need to delete the entire file and rewrite it. So store all bans in an array, delete the file, and check whether the ban is in the array when writing it again.