file write change

open file before writing