System service 3 returns a value in eax. When the system service
reads successfully, eax returns the number of bytes actually
read. At the end of file, eax returns a 0 because it cannot read
past the end of a file. Use this to terminate the outer so you can
exit the program.
I did not know that in div, the register that will eventually
store the remainder supplies the most significant portion of the
divident. As a result, you need to initialize dx to zero right
before the divw instruction.