I object to using assignfile and closefile: these are re directions and not even inlined to assign() and Close() which is proper Pascal syntax. This silly syntax should be deprecated.
Furthermore: read() reads a variable of the size of file type. If that is untyped, it will read a char at a time. Readln() reads up-to-and -including a LineBreak.
But the above example is correct except for my first comment line here, it still works but is not optimal nor is it standard Pascal.
(There is an exception, codepage related, though, as I explained last week....
)