Added write to file method, added comments, fixed logic bugs, found a better solution, implement operator =  and cctor