Added malloc for linecopy to avoid seg fault