refactoring complete and file writing and reading done