adapted to work witn argv as file input