Fixed file writing error.