added writing to file and negation changes of variables