HI,
the filehandle variable value will probably change each run and it will probably never be equal to one.

Code:
if ( filehandle != 0 )
{...



Salud!