Updated version

changed f.close() to close the files properly.