This is leaving the file lock open until garbage collection runs - use IO.read if it's a string or File.open{ ... } if not