Modified implementation of copyFileContent such that writing only occurs when there are bytes to write.