saving filtered data into a file