Code:
on !*:join:*: {  
set %j $chan  
set %s $address($nick,2)  
set %s1 $right(%s,-4)  
set %s2 %s1 $+ : $+ 04 $+ $nick 
if ( %j == #channel ) && ( %s1 isin $read(blah.txt,w,%s1) {     
set %s3 $readn + 1     
echo #channel 04***** 12 %s2 01has entered before as 12 $read(blah.txt,%s3)     
write -l $+ %s3 blah.txt %s2   
set %s4 $readn     
write -l $+ %s4 blah.txt %s1  
}  
else {    
if ( %j == #channel ) { write blah.txt %s1 | write blah.txt %s2 }  
}
}


the $readn - 1 was incorrect and was writing to the wrong line it needed to be just $readn i also added a On Exit Event
Code:
  
on 1:EXIT: write -c blah.txt

that clears the file so it doesnt keep building up