writes to file when performing search