Unfortunately you cannot simply use the block number to do this because of something called 'blockchain reorganization'. I encourage you to Google this and read about it. Here are some links:
How should I handle blockchain forks in my DApp?
Syncing events on Database - Dealing with blockchain reorganization
How can a DApp detect a fork or chain reorganization using web3.js or additional libraries?
If two miners mine a block at the same time, there will be 2 blocks A and B with the same block number but with a different block hash. These blocks might not have the exact same set of transactions.
If you received block A first and process its transactions, but then another miner mines block C on top of B, block A will be reversed entirely and you will have to un-process its transactions and replace them with B & C.
The end of the blockchain would look like this:
\ 15788 15789
\___ B ------------ C
Using your method, you would process block A and then block C. You will now process duplicate transactions that are in both A and C, and you will miss transactions that are only in block B.
I hope this helps you understand the problem and why you can't just simply remember the last block number you've processed. You will have to look at the block hashes and implement code that un-processes transactions if a blockchain reorganization is detected.
If you do not want to implement code that un-processes transactions, you can instead only process a block if ~10 other blocks have been mined on top of it. You will have to rely on no blockchain-reorganizations of more than 10 blocks happening. I would still recommend that you implement code that detects such a large blockchain-reorganization and prevents your system from doing wrong things.