me thinks that the easiest way to handle this is to read the whole file to memory.

even though your file is 500M in size, that is easily diggable into swap-space [Wink]

that would also be a lot easy to control...
_________________________
!

download KiXnet