I do check for a failure on open(); I just left that out as not relevant to the question. The code is running on a linux system (FC3) so is it sane enough so that I don't need to do the file locking? The string I write out may have embedded carriage returns if that makes a difference.