Fixed int to long in build_sequence

Similar problem in build_sequence function. Int overflow in large file
iteration.