I would have close-voted this question for at least two different reasons:
It appears that you are looking for help with some code, but there is neither a specific error message nor code that is not working. Both are required for assistance with debugging; see How to create a Minimal, Reproducible Example.
It is not clear exactly what I could do to produce a satisfactory answer. Your question states:
I'd like to check the 'correctness' of the file
I don't know what correctness is, and unless I know that, I cannot help you check it.