add the write attribute in the main function to allow the mocking, and add the test case for the main() funtion.