Fixed some bug for handling file input