Serial stops returning data. java.io.IOException: Device not configured in write

No, that probably won't work. I don't know why you want to read two switches with one input.
Are you trying to read if both switches are in a particular state, or one of them is ?
I guess you know the difference between AND and OR.

Anyway, make sure you think that through.

So you are saying, that everything in your scenario is exactly the same, when you try
it with the UNO and the MEGA ?