Bug fixed

I have made a few appropriate changes in the code. It is no longer creating empty 0 byte files.