Fixing bugs caused by file length of zero bytes