you're using a DictReader, which is good to read data, but not as good to read and write data as the original file, since dictionaries do not ensure column order (unless you don't care, but most of the time people don't want columns to be swapped). I just read the title, find the index of the column title, and use this index in the rest of the code (no dicts = faster)

when you write you append to the csv. You have to delete old contents, not append. And use newline='' or you get a lot of blank lines (python 3) or "wb" (python 2)

when you read, you need to store all values, not only the one you want to change, or you won't be able to write back all the data (since you're replacing the original file)

when you modify, you do overcomplex stuff I just replaced by a simple replace in list at the given index (after all you want to change r to x at a given row)

Here's the fixed code taking all aforementioned remarks into account

EDIT: added the feature you request after: add a c after x if not already there, extending the row if needed