The reason I'm asking is because I recently encountered this question, and I can't make my mind up if it's off-topic here or not. I asked OP to include the imports so I could run the program, but because certain names (
file_name, ...) were not defined, I gave up.
Even if those names were defined, a body for the
except-clause is missing (which is a fatal error in Python). It kind of sounds like OP is asking for a review of the
while-loop and its break conditions in general. Normally, that would be on-topic here, but I feel the question is missing too much context.
This help center article clearly states:
In order to give good advice, we need to see real, concrete code, and understand the context in which the code is used. Generic code (such as code containing placeholders like foo, MyClass, or doSomething()) leaves too much to the imagination.
Is the question off-topic? Why (not)?