File size limit

Improves on pull request #474 submitted by @fanha99.