Thierry - Check out the StringIO module. It will allow you to buffer the whole file into a string, and then give you a pseudo file pointer to the string buffer, so that your "fp.write"s will work unchanged. -- Paul