I have a problem - big one

I have a $db file. (easy .txt file).
$db looks like:
User1|Pass1
User2|Pass2
User3|Pass3
User4|Pass4
Now I want to make a function !deluser.
The problem is that it should delete using the username. I already got a proc which does this by linenumber, for example !deluser num 3 (line 3 - User3) - thats no problem, but the problem is getting the line by just the username and the number. I dont want to use !deluser num - I want to use !deluser User2. Can anyone help me coding that proc ? I really don't get it working. It should work like this:
!deluser User3
-> Searches User3 in $db and deletes the WHOLE LINE out of $db.
After that command $db looks like:
User1|Pass1
User3|Pass3
User4|Pass4
Can anyone help me with that?
Big thanks.