I found some old code by me, myself and I, but it is not correct and I can not see where it fails.
DON'T comment on the programming style - that is sound, but old -, but find the error, please...

program hexdump;
{ Simple Hexdump, unix like clone.
Has error! Where?
This is an adapted version of my original.
(c)1991-2024, Thaddy de Koning.
Use as you like, no license }
{$mode objfpc}{$I-}{$H-}
const
maxchar = 15;
type
TByteOrChar = packed record
case boolean of
false:(asByte : packed array[0..maxchar] of byte);
true :(asChar : packed array[0..maxchar] of AnsiChar);
end;
function ByteToHex(const value:byte):string;inline;
const
HexDigits = '0123456789ABCDEF';
begin
ByteToHex := HexDigits[hi(value)+1]+HexDigits[lo(value)+1];
end;
var
f: file of TByteOrChar;
bor: TByteOrChar;
i,r: integer;
begin
if ParamCount > 0 then
begin
Assign(f,paramstr(1));
filemode := 0;
reset(f);
r:= IOResult;
if r = 0 then
begin
while not eof(f) do
begin
write(HexStr(FilePos(f) * 16,8):10);
read(f,bor);
for i := 0 to maxchar do
begin
write(ByteToHex(bor.asbyte[i]):3);
if (bor.asbyte[i] < 32 ) or (bor.asbyte[i] > 127 ) then bor.aschar[i]:='.';
end;
writeln('|':2,bor.asChar,'|');
end;
close(f);
end
else
case r of
2:writeln('File not found');
5:writeln('Access denied');
else
writeln('A less common error occurred:',r:4);
end;
end
else
writeln('Use: hexdump <filename>');
end.
Problem at hand is that I am missing the last line, compared to e.g. the standard hexdump on linux.
I can't see it? must be easy for old hands...

The error is the last line of the output missing.