changing file openmode from a to w