file writing functions update