in reply to readline() on closed filehandle

One way to get that warning message is if the open failed for your input file. Check if the open succeeded, for example, with autodie.