Index: main/file.c =================================================================== --- main/file.c (revision 260279) +++ main/file.c (working copy) @@ -1109,6 +1109,11 @@ if (fd > -1) { errno = 0; fs = get_filestream(f, bfile); + + if ((fs->write_buffer = ast_malloc(32768))){ + setvbuf(fs->f, fs->write_buffer, _IOFBF, 32768); + } + if (!fs || rewrite_wrapper(fs, comment)) { ast_log(LOG_WARNING, "Unable to rewrite %s\n", fn); close(fd); @@ -1136,9 +1141,6 @@ fs->vfs = NULL; /* If truncated, we'll be at the beginning; if not truncated, then append */ - if ((fs->write_buffer = ast_malloc(32768))){ - setvbuf(fs->f, fs->write_buffer, _IOFBF, 32768); - } f->seek(fs, 0, SEEK_END); } else if (errno != EEXIST) {