Added loop for automatic sync
Fixed filename bug when filetype was empty