 <p><a href="https://ruby-doc.org/core-2.3.0/IO.html#method-c-readlines" rel="nofollow"><code>IO#readlines</code></a> expects a string, not a regular expression. But the desired behaviour might be easily achieved with <code>read</code> + <code>split</code> since according to the documentation <code>readlines</code> “reads the entire file”:</p> <pre><code>f.read.split /\!|\.|\?/ </code></pre> <p>Please also read the valuable comment by @tom-lord with a significant improvement suggestion.</p>