I cannot reproduce this, which version of mIRC are you using? The following command gives me 7 lines not 5:

//write -c test.txt $+(1aaa,$crlf,2bbb,$crlf,3ccc,$crlf,4ddd,$crlf,5ee,$chr(26),ee,$crlf,6ffff,$crlf,7gggg) | echo -a $lines(test.txt)

I also see the full 7 lines from:

/filter -fs test.txt *

The $chr(26) is the Ctrl+Z character, and in the early days of DOS, it was known as the "end of file marker", and back then everything past it was ignored. In fact, even now you can see that the TYPE command here will show only the contents prior to that Ctrl+Z:

/run cmd /k type test.txt

If you are still seeing the 5, please show the content of your disk file when you show it as a mime string:

//bread file.txt 0 $file(file.txt).size &v | echo -a $encode(&v,bm) -> $bvar(&v,1-).text