From your description, I understand that you want to loop through some plain text from System.in and when encountering errors, call method2 to close the Socket. I think you can establish a check to first see if the specific line would throw an error or not.
Again, I assume that the error happens when sending to the Socket. Therefore, I think you can create a dummy instance that would get the problematic line instead of sending it directly to the current one. This way, you assure that you can predict an error line and keep it away from the main instance.
Another suggestion would be to have your own way of identifying errors, instead of having to send lines directly to the client and see if they worked or not, you can have a method that would return whether the line is problematic or not based on some test cases.
I am sorry if this won't work for you, but I tried my best as I am a beginner :) More details would help as well, because with the ones provided by you I can't be sure of coding a solution, as I don't know the full problem.