> but the program is running perfectly..
Just because it runs without crashing and produces an output file is not a sign of perfection.

You're not addressing the issues raised in my previous post.

Given 1/122/3
You need to find a way of making sure it decodes as
1/122/3
and not as
1/122/3
This is what Cactus_Hugger was talking about.

It might be easier if you always wrote the length out as 3 digits, say
1/0122/003
If you know the length is always 3 digits, it makes it easier to deal with.