This question evaluates streaming file I/O, memory-efficient data processing, UTF-8 handling, and robustness with edge cases such as blank lines, trailing newlines, and files containing fewer than K non-empty lines, while also requiring reasoning about time and space complexity.
Given a large UTF-8 text file, write a program that prints the K-th non-empty line. Do not load the whole file into memory. Specify how you handle files with fewer than K non-empty lines, blank lines, and trailing newline behavior. Provide code in a language of your choice and discuss time and space complexity.