What is a file descriptor?Why do we need them? 
What and Why? - File Descriptors
files;filesystems
A file descriptor is a number that represents an open file in a process. It's a way for the program to remember which file it's manipulating. Opening a file looks for a free number and assigns it to the file in that process's file descriptor table; closing the file removes the entry from the process's descriptor table. There is no relation between file descriptor n in a process and the file descriptor with the same number in another process.Every file has three of them (stdin, stdout, stderr) is nonsense. Processes have file descriptors, not files. Processes can and often do have more than three file descriptors, and can have fewer. Stdin, stdout and stderr are the names for file descriptors 0, 1 and 2 because they have a conventional meaning: stdin (standard input) is where the program is supposed to read user input (if it wants to), stdout (standard output) is where the program is supposed to write the data that it produces (if it wants to), and stderr (standard error) is for error messages. Stdin and stdout are of use in programs intended to be used on the command lines and especially in pipelines; I invite you to read what is meant by connecting STDOUT and STDIN? and (more advanced) How can a command have more than one output?