added tmp files
added flush()