in reply to Re: Filehandle problem
in thread Filehandle problem

That was not the solution. If you test the original code with some debug values on the variables, the lower branch is writing to the file as supposed.