I thought about using read, however, since the numbers are not constant length, a single number could be split between two chunks. This would introduce additional complexity to detect and merge such split numbers.
I should've included such examples in the sample input from the start, I've updated the question.