Hi Prashant--
Flush works for me. If I put() a string to a file, call flush(), and then examine the file, I see what I just wrote in the file. Is it possible that your code is not actually writing to the file, at least in some cases (or is writing an empty string)?
You might try adding some response() calls to debug your code, to make sure it is executing as you expect. Try checking the return value from put(), which will be -1 if the write failed.
--Clay