he said he made the file.
thus, there are at least 4 possibilities with his posted code:
- he has no rights to write to the file
- the drive is full
- he is not actually running the posted code
- the code is part of larger file and it exits before it or jumps over the part

but, what the actual reason why the write fails will be shown with the error showing code I modified for him.
_________________________
!

download KiXnet