prepared data formatting for output file
implemented writing results to disc