Add Writing

- delete filter function cuz it’s not needed
- write the result to output file