Modified writing to file & implemented serach by data