Although you probably don't want to write to the input.
You may need to clarify what you are trying to do here. Your code doesn't seem to match your expectations. Perhaps experiment with a simpler bit of code to get the hang of the relationship between digitalRead, digitalWrite, etc.