Answers should answer the question. In the first case, try something like:
Your error message is because you forgot to add one (or subtract one, or initialize x or whatever) on line 7. [show corrected line of code.]
But in the bigger picture, reading the file [or whatever] like this is very inefficient and will not scale. Please look at the xyz function/class/framework/library as a replacement for [the inefficient thing OP is using] if you intend to have more than 10 users [or handle files over 1k, or whatever.]
You're sure their approach is wrong and not to a "coding standard" but you don't know what the app is being used for. It's possible what they are doing is fine in context. It's also possible it's not. If you actually answer the question as a sort of "price of admission", you can include other advice like "don't do it that way" but such advice is better if it's precise and bounded. It's better to say something is slow for large files, or won't handle large numbers of requests, than to say it doesn't meet a coding standard.
You can use a similar approach to say "and what's more when you fix line 7, you are going to have a problem with line 14 because it's missing a comma' - or whatever.
If you don't have an actual answer for the person, just want to say "don't do it that way" or "it's not causing this error but your line 14 is just horrible" - well, that is why comments were invented. And if you can't comment yet, then try to be patient until you can, and don't misuse answers for comments. (But remember, if you answer, you can include comment-like material in your answer as well.)