People sometimes ask "Why do text files have the EOF character?" (^Z - 0x1A)
This dates back to very early editions of DOS (and even some pre-DOS "personal" OSs like CP/M).
These systems did not track or know the size of files to the byte level.
Files were allocated in sectors (usually 512 bytes) and early OS didn't have the capability to make files NOT a multiple of 512 bytes.
Executables were't a problem, the file contained all the code and static data that was needed and "extra garbage" in the last sector was not different that uninitialized memory (could be anything).
Text however has a problem ... suppose you make a text file containing just "Hello World" - you don't want to process such a file in 512 byte "chunks".
So... the idea of a "text EOF" character - in the above example "HelloWorld"^Z would be written to the file, and the OS would know that when processing a text file, ^Z means "END".
I actually use behavior in ImageDisk .IMD files - although the file is "binary in content", it begins with a few lines of text:
Line1 = ImageDisk version and date/time file was created.
Line2+ = Text comment/description provided by user.
^Z (0x1A) EOF
... actual ImageDisk binary image data follows (up to physical EOF)
This has the nice benefit that you can simply TYPE an .IMD file to see when it was made and how the maker described it!
https://dunfield.themindfactory.com ; "Daves Old Computers" ; SW dev addict best known:
ImageDisk: rd/wr ANY floppy PChw can ; Micro-C: compiler for DOS+ManySmallCPU ; DDLINK: simple/small filetransfer(w/o netSW)via Lan/Lpt/Com