Input file handling added
Main function refactoring