Fixed file writing