This is wrong code. $filename isn't from the ctcp event scope..