fixed case when only one file has to be written.

Signed-off-by: Johny Jose <johny@playlyfe.com>