I found a method I vaguely understand on Baeldung that I repurposed for this task, but I get the gist of it. We check the string at the end of the last "." and if it equals txt then we create a new FileInputStream, otherwise we close and throw the exception. It seems straightforward. Did I miscalculate the index or something?