writer.writeheader()
fout.write(f.getvalue())
for row in testDict:
    f.seek(0)
f.truncate(0)
writer.writerow(row)
fout.write(f.getvalue())
f.close()
Can you upload to S3 using a stream rather than a local file?