Fix bug in file writing