uniqid() for the filename may work well.

I was about to argue that appends were atomic, but I'm not sure if that's true at all write sizes and block sizes.