[Bug] Stream fetching has not considered re-org situation
Your code looks neat but I found a problem. Fetching block chain latest stream data can not directly insert to the storage file. Because re-org may happen after a while. See What's a re-org in Alchemy: https://www.alchemy.com/overviews/what-is-a-reorg
Thanks for the report.
In bitcoin, it is safe after 6 blocks are confirmed. Not sure if Ethereum has such a mechanism. Further research is needed.
You can check the Re-Org (latest blocks may be rolled back after a while) situation using following way: Request for the finalized block number and the latest block number, the blocks between are possible to have Re-Org situation. You can use a queue to check the block hash of finalized block. If it's different from previous block hash with the same block number, then you can say it's a Re-Org block.

The mock curl:
curl --location --request POST 'http://localhost:8545' --header 'Content-Type: application/json' --data-raw '{"jsonrpc": "2.0", "method": "eth_getBlockByNumber", "params": ["finalized", false], "id": 0}'