fixed file write