This would be an excellent place for a state machine. Create a state machine with states from S. You should have a state for "I haven't matched anything", one for "I've matched the first character," one for "I've matched the first two characters" and so on. In your example, we would have 4 states { "", "1", "14", "141" }. The final state is terminating. If you mach the whole string (141), then you have found your first match in the infinite string.
Now you can build your state transition diagram. The key to building this is that you can fail to match the next character, but not have to start over at the beginning. 141 is a bad example, but consider 444441. If I were to be matching "132444444..." I clearly start matching 444441 at the obvious point, but when I see a "4" when I wanted to see a "1", I shouldn't start over. I've still got a match of several 4's in a row. Maybe the next character will be a 1!
We can write up a transition diagram. In this case, I'll notate it with the current state on the left, a colon, and then a set of transitions on the right side of the colon. The inputs will be unquoted digits, and the new states will be quoted strings. In your simple example, 141, the transition diagram is:
"": 1 -> "1" other -> ""
"1": 4 -> "14" 1-> "1" other -> ""
"14": 1 -> "141" other -> ""
"141" terminates
This clearly can process each additional character of the string in O(1) time.
In a more complicated example, such as S = "5451" we need to take into account the possibility of a partial match. Otherwise, the process is the same
"": 5 -> "5" other -> ""
"5": 4 -> "54" 5-> "5" other -> ""
"54": 5 -> "545" other -> ""
"545": 1 -> "5451" 4-> "54" 5-> "5" other -> ""
"5451" terminates
Note that on "545", there are many possible transitions which capture the fact that there were partial matches.
If you are interested in prior art KMP is a good algorithm to explore. There are also more exotic sub-linear ones which can actually skip characters entirely (as long as there's a way to go back and visit those characters if a potential match shows up).