add function writing which writes counting function results to results.txt file and covert counter object to string