This fails due to how mIRC handles the first line in a text file when this line is a number. See /help $read
You'll need to circumvent this by using:
Code:
on *:TEXT:!add:#:{
  write -l1 number.txt $calc($read(number.txt,0) +1)
}