Added main function
Fixed a bug that overwrite one file if the properties were unordered