Here is a sed solution
sed -i -e1r/dev/stdin -e1N $1
Using a named pipe for large files
test -s 1.fifo||mkfifo 1.fifo cat largefile > 1.fifo & printf '0r 1.fifo\nw\nq\n'|ed -s $1 curl -A "" -4o 1.fifo https://example.com/largefile.gz & gzip -dc largefile.gz|tail -100|sed -i -e 1r/dev/stdin -e1N $1
od -tx1 -An|sed 's/^/w /'|ired -n $1 /dev/stdin
Here is a sed solution
However this still has a limitation. The target file must be more than one line.Using a named pipe for large files