Prevent "method `write' not defined in File" failure on some Ruby versions