changed to O_APPEND for writing; files being truncated