added check for file exists.