Updated writing - directly to file