# Net/FTP: failed download creates empty file

**URL:** <https://www.ruby-forum.com/t/net-ftp-failed-download-creates-empty-file/105996>\
**Category:** Ruby\
**Created:** [June 5, 2007, 2:01pm UTC](https://www.ruby-forum.com/t/net-ftp-failed-download-creates-empty-file/105996 "2007-06-05T14:01:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ronaldfischer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/67e7ee/32.png) [@ronaldfischer](https://www.ruby-forum.com/u/ronaldfischer)\
**Post date:** [June 5, 2007, 2:01pm UTC](https://www.ruby-forum.com/t/net-ftp-failed-download-creates-empty-file/105996/1 "2007-06-05T14:01:52Z")

</div>

I’m downloading a file via FTP like this:

require ‘net/ftp’  
ftp=Net::FTP.new(hostname,userid,password)  
begin  
ftp.getbinaryfile(‘fluffi’)  
rescue Net::FTPPermError  
puts “download #{filename} failed (#{$!.to\_s.chomp})”  
end

This works basically fine, with one minor glitch: If the file (‘fluffi’)  
does not  
exist (i.e. the exception is thrown - “download fluffi failed (550 Can’t  
open  
fluffi: No such file or directory)”), there is still a file ‘fluffi’  
created  
with length 0.

Is this a bug or intended behaviour?

Ronald
