As Richard has said, it's going to depend on the data processed, and we have no access to your file system - the debugger is (as always) your best friend here as it can show you exactly what is going on while your program runs.
So, it's going to be up to you.
Fortunately, you have a tool available to you which will help you find out what is going on: the debugger. How you use it depends on your compiler system, but a quick Google for the name of your IDE and "debugger" should give you the info you need.
Put a breakpoint on the first line in the function, and run your code through the debugger. Then look at your code, and at your data and work out what should happen manually. Then single step each line checking that what you expected to happen is exactly what did. When it isn't, that's when you have a problem, and you can back-track (or run it again and look more closely) to find out why.
Sorry, but we can't do that for you - time for you to learn a new (and very, very useful) skill: debugging!
But do yourself two big favours:
1) Stop using really short variables names: use meaningful names instead of "a", "p", "jj", "y", "c", and so on and your code becomes both much more readable, but more reliable too as it's more obvious when you use the wrong variable by mistake ...
2) Stop swallowing exceptions.
catch(IOException e)
{
}
may make an error "go away" but it quite possible that a swallowed exception is causing the problem you have seen. If you want to ignore an error, log the error to a file in the
catch
block so if something goes wrong you can look back to see what problems you ignored.