writing result into a file