in reply to Getting file size Zero
From the docs
An explicit close() is required if the file must be closed prior to performing some external action on it such as copying it, reading its size or attaching it to an email.